import re def find_hamlet_lines(file_path): with open(file_path, 'r') as file: for line in file: line = line.strip() if re.search(r'\bHamlet\b', line): print(f"{line}") file_path = './simple.in' find_hamlet_lines(file_path)