I have a config file that i would like to add a space (\' \') to the end of every line in the file
File example:
#xxx configuration
IPad
You don't need to know the length of your file. In python files are iterators that yield lines. No need for c-style for-loops.
So something like this should work for you (python3 or from __future__ import print_function
):
with open('file.in') as infile, open('file.out', 'w') as outfile:
for line in infile:
print(line.strip() + ' ', file=outfile)