def main():
word = input("Enter word to search: ")
list = open('lol.txt', 'r', encoding='latin-1')
lines = list.readlines()
list.close()
flag = 0
for line in lines:
line = line.strip()
if line.find(word) == -1:
pass
else:
print(f"{line} is here sir...")
flag += 1
if flag == 0:
list = open('lol.txt', 'w', encoding='latin-1')
list.write(word)
list.close()
main()
Im just trying to insert a given word into the wordlist but it keeps on overwriting the wordlist.. how would I go about append the word to the end ?