I want to check if a string is in a text file. If it is, do X. If it\'s not, do Y. However, this code always returns True for some reason. Can anyone see what i
True
If user wants to search for the word in given text file.
fopen = open('logfile.txt',mode='r+') fread = fopen.readlines() x = input("Enter the search string: ") for line in fread: if x in line: print(line)