It appears that what happens is that your file disappears (basically).
Try this, create a file test.py and put the following in it:
import os
f = open('out.txt', 'w') # Open file for writing
f.write("Hi Mom!") # Write something
os.remove('out.txt') # Delete the file
try:
while True: # Do forever
f.write("Silly English Kanighit!")
except:
f.close()
then $ python test.py
and hit enter. Ctrl-C should stop the execution. This will open, then delete the file, then continue writing to the file that no longer exists, for the reasons that have previously been mentioned.
However, if you really have a different question such as "How can I prevent my file from being accidentally deleted while I'm writing to it?" or something else, it's probably better to ask that question.