The standard /bin/echo
can be used to add that newline to the end of the file for you:
$ echo -n 'ssss'>test $ file test test: ASCII text, with no line terminators $ hexdump -C test 00000000 73 73 73 73 |ssss| 00000004 $ echo >> test $ file test test: ASCII text $ hexdump -C test 00000000 73 73 73 73 0a |ssss.| 00000005 $
Another option would be to add it in your Python code:
text_file = open("response.txt","w") text_file.write("%s" % response) text_file.write("\n") # <-- newline added here text_file.close()