Basically, I have a test.txt
file where my goal is to
- Read the first line
- Use the current first line
- delete the current line so the next comes first in the file
- Repeat until EOF
I know I could store the file in a list, but I'm looking for a way to accomplish using an iterator.
I have tried,
with open("test.txt", "r") as f:
for line in f:
print(line) #Use the line in some way (example purposes)
# del line (looking for something like this maybe)
Which logically doesn't work since I'm not writing to the file. What would be the best way to accomplish this in Python using an iterator?