f = codecs.open('import.txt', 'w', 'utf-8')
for x in list:
string = "Hello"
f.write(string+'\n')
f.close()
For some reason this code does not write newlines to the file, as it would do if I had used the open
function instead of codecs.open
.
How do I solve this?