# How to read complete text file line by line using Python?

PythonServer Side ProgrammingProgramming

## Example

You can use the following to read the file line by line:

f = open('my_file.txt', 'r+')
print line
f.close()

You can also use the with...open statement to open the file and read line by line.

### For example

with open('my_file.txt', 'r+') as f:
print line