lengths = [10, 17, 5, 14, 0]
for line in inputfile:
    line = line.split()
for field, fieldlength in zip(line, lengths):
    output.write(field.ljust(fieldlength))
output.write('\n')
Align columns in a text file