handler = open('textfile.txt') for line in handler: line = line.rstrip() #rstrip() method removes characters at the end a string. if not line.startswith('From:') : #For this case, we remove any lines between lines staring with "From:"" continue print(line)