Python: how to read a file line by line?

Example:

with open("file.txt", "r") as f:
Reading files is a common operation in programming.

Solution:

with open("file.txt", "r") as f: for line in f: print(line.strip())

Beginner's Guide to Python