I would like to periodically check whether a certain word has been saved to a text file with python. Whenever I run the function it deletes anything in the text file regardless of what I tell it to look for specifically.
import threading
def ban():
threading.Timer(0.1, ban).start()
ff=open("htfl.txt","r")
liney = ff.readlines()
ff.close()
ff=open("htfl.txt","w")
for line in liney:
if line!=("HTFL"):
liney = liney[:-1]
print("true")
ban()
It has to run every few seconds as it is part of an instant messenger I am working on which ought to ban rude words for example or certain usernames.