Python Tutorial, Release 3.9.5 After the statement is executed, the file f is always closed, even if a problem was encountered while processing the lines. Objects which, like files, provide predefined clean-up actions will indicate this in their documentation. with open("myfile.txt ") as f: for line in f: print(line, end ="") Chapter 8. Errors and Exceptions 64