with open('book.txt', 'r', encoding='utf-8') as f: arr=f.readlines() for item in arr: if item.lower().find('love')!=-1: print(item)