I am working in python tkinter and I am trying to write a code for writing some contents to a file and saving it. I have used filedialog to do so. I wish to write the contents in every next line. While there are so errors in running the code, even after writing "\n", it is not writing to the next line. The "\n" just adds a space after. How to resolve this issue?
I have tried using the "\n" keyword in different ways possible. Yet, it is not writing to the next line. Instead it only adds a space after, just like   does.
Following is the relevant part of the code:
def save_file(event=""):
data = filedialog.asksaveasfile(mode="w", defaultextension=".html")
if data is None:
return
data.write("Content-1" + "\n"+ "Content-2" + "\n")
data.close()
I expect the data to be written in the file as:
Content-1
Content-2
But it is writing to the file as: Content-1 Content-2