> For the complete documentation index, see [llms.txt](https://til.devjugal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.devjugal.com/python/read-a-file-line-by-line.md).

# Read A File Line By Line

We can read a file line by line in Python as -

## Example

```python
>>> with open("file.txt", "r") as file:
...     lines = file.readlines()
...
>>> for line in lines:
...     print("{}".format(line.strip()))
...
Line 1
Line 2
Line 3
```

***Source:*** [***GeeksForGeeks***](https://www.geeksforgeeks.org/read-a-file-line-by-line-in-python/)
