what I am trying to do is add a string only if not available in a text file The problem is I can't read the content of the text file within an if statement
import random
import time
def random_srting(length=1):
digits ='abcdefghijklmnopqrstuvwxyz1234567890._'
return ''.join(random.choice(digits) for i in range(length))
Input = str(input())
with open('4LWordList.txt','a+') as f:
while Input != "s":
time.sleep(1)
word = (random_srting(1)+".abc")
if (word in f.read()): #here is the problem 'word' isn't being checked in 'f' because it's not reading the content of 'f'
print("skip : "+word)
elif (word not in f.read()): #same problem here
f.write(word+"\n")
print("add : "+word)