Given the following piece of code, I'm looping through a file to process some data. When that data is processed I want to remove the item from the words list and move it to the complete list.
I'm able to populate the completed file but not remove the line from the initial file. Does anyone know the syntax to remove that current line?
I have had a search around already but cannot find a specific bit of syntax for this.
startFile = open("words.txt", "a")
completedFile = open("completed-words.txt", "a")
with open('words.txt') as f:
for line in f:
# do something with the line
completedFile.write(line)
print(line.rstrip() + " - complete")
startFile.close()
completedFile.close()