use mode 'a' to append to a file.
you should use the with construct as then you don't have to close the file, it's done automatically at end of operation (you actually forgot to close file in above example).
It's syntax is:
you should use the with construct as then you don't have to close the file, it's done automatically at end of operation (you actually forgot to close file in above example).
It's syntax is:
with open(filename, mode) as name: for line in name.readlines(): ...output can be written as part of same statement:
with open(path_input, 'r') as f_in, open(outname, 'a') as f_out: ...