Reputation: 35
I pull some data from DB and save it to a text file called "databaseoutput.txt". When I run the code below all lines are displayed except the last one - and I know it's there because when I open the file the line that's missing when I run the code below is present
with open("databaseoutput.txt", 'r', encoding='utf-8') as f:
for line in f:
print(line)
What can be causing this?
Upvotes: 0
Views: 765
Reputation: 11
I just had the same problem as you. When creating my text file I forgot to close it with:
f.close()
Upvotes: 1