from optparse import OptionParser clparser = OptionParser() (clopts, clargs) = clparser.parse_args() infilename = clargs[0] infile = open(infilename, "r") header = True for line in infile: state = line[152:163].strip() if header or state == "absent": print line[0:163] header = False