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