So i have a text file named words.txt and it contains 3 words:
apple
ship
door
And what I want to do is to ask the user to input a word and then search the file to see whether there is such word and if not add it:
def search(word):
    file = open("words.txt", "r+")
    for line in file:
        if line == word:
            return False
    file.write(word + "\n")
    return True
And then I use the function to check and print the result, but the problem is that when I input the word ship or any other word that's in the list it supposedly says that it's not there which it is.
 
     
    