This should be as simple as:
with open('somefile.txt', 'a') as the_file:
the_file.write('Hello\n')
From The Documentation:
Do not use
os.linesep
as a line terminator when writing files opened in text mode (the default); use a single'\n'
instead, on all platforms.
Some useful reading:
- The
with
statement open()
'a'
is for append, or use'w'
to write with truncation
os
(particularlyos.linesep
)