handler = open('textfile.txt') for line in handler: line = line.rstrip() if not '@uct.ac.za' in line : continue print(line)