"James T. Dennis" wrote: > > Could try this: > > def chomp(line): > if line[-1]=='\n': > line=line[:-1] > return line Just make sure you pass chomp() only lines that are not equal to the empty string ''. >>> line = '' >>> line[-1] Traceback (most recent call last): File "<stdin>", line 1, in ? IndexError: string index out of range -Peter