You can also do it with simple generator expression: for line in (l for f in (file1, file2) for l in f): # do something with line