with open('learning_python.txt') as learning_python : print(learning_python.read()) for line in learning_python: print(line)Why not do it all

Hello, questioner , I just tried your code , It's printable , But it's not standard enough , Look at this
with open(r'C:\Users\17591\Desktop\a.txt', "r+", encoding="UTF-8") as learning_python: # print(learning_python.read()) for line in learning_python.readlines(): print(line)readlines Means to store the contents of each line in the list , then line Print out