python write text file line break code example
Example 1: python write text file on the next line
file = open("sample.txt", "w")
file.write("Hello\n")
file.write("World\n")
file.close()
Example 2: python write line break
new_line = "This new line will be added.\n"
with open("sample.txt", "a") as a_file:
a_file.write("\n")
a_file.write(new_line)