i have an listing that read files from a given directory, and then prints it out to console, and now i am wanting to output that list of files to a file, and i got that working except it puts it all on one line, how can i add a new line? I have tried \n but it dose nothing. I know im using it incorrectly. here is my code block.
for path in files:
print(path)
# Open the file for writing
file = open('looking-for.txt', "w", encoding="utf-8")
# grab the list for writing
content = str(files)
# write out the header to the file.
file.write("----------------------------------\n")
file.write("| Looking for files |\n")
file.write("----------------------------------\n")
# write out the list to a file
file.write(content)
# close the file.
file.close()
heres what i have tried.
this dose not give me a new line.
file.write(string)
file.write("\n")
here is what I get.
drive:\path\to\file1, drive:\path\to\file2, drive:\path\to\file3
etc.
here is what I am trying to achieve.
drive:\path\to\file1
drive:\path\to\file2
drive:\path\to\file3
etc.