It would appear that you're looking to cycle through the contents of the smaller file
With awk
awk 'NR == FNR{a[++i]=$0; next}; {print $0, a[FNR % i? FNR % i: i]}' smaller_file larger_file And python
from itertools import cycle, izip with open('larger_file') as f1, open('smaller_file') as f2: z = izip(f1, cycle(f2)) for l, m in z: print l.rstrip('\n'), m.rstrip('\n')