With can help automatically close files for us, with open…
1 2 3 4 5 6
with open("test.txt", "r") as f: # f.read() to read the entire file at once # Or for line in f: # Now we read the file in a line-by-line # The file f is now closed