# takes both arguments on one line argument_str = input('grep: ') search_str, filename = argument_str.split(' ') search_str = search_str.lower() # still make this lowercase textfile = open(filename, 'r') line_num = 0 for line in textfile: line_str = line.strip() line_num += 1 # search for string in lowercase version of line if line_str.lower().find(search_str) >= 0: # but print the original version of line print(line_num, line_str) textfile.close()