0

I want to edit the file and the new text I send will be on the first line, not the bottom one. I use this:

with open("OUTPUT.txt", "a") as myfile:
    myfile.write("row #2 text")
    myfile.write("\nrow #1 text")

But it will just add the text to a new line.

Thanks

SOLVED!

Yarzz
  • 5
  • 2

1 Answers1

0

with file('filename', 'r') as original: data = original.read() with file('filename', 'w') as modified: modified.write("new first line\n" + data)

Yarzz
  • 5
  • 2