code for showing contents of a file and printing it in python

import os

with open("filename", "r+") as file:
    content = file.readline()
    while(content!=""):
      	print(content)
        content = file.readline()
    file.close
    

Here is what the above code is Doing:
1. Opening the file in read+ mode. This means that we can read from the file, and write to it.
2. Reading the first line of the file into the variable content.
3. Printing the contents of content.
4. Reading the next line of the file into content.
5. Going back to step 3.
6. Once we reach the end of the file, the while loop will end, and the file will be closed.