with open('filename.txt', 'r') as file: for line in file: print(line.strip())
The idiomatic way: iterate directly over the file object in a for loop, which is memory-efficient and automatically handles closing.