You are trying to open each file twice! First you do:
infile=open('110331_HS1A_1_rtTA.result','r')
and then pass the infile (which is the file object) again to the open function:
with open (infile, mode='r', buffering=-1)
open , of course, expects its first argument to be the file name, not the open file!
Open the file only once, and everything will be fine.
Gareth Rees Jul 13 2018-11-11T00: 00Z
source share