This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Geforce Fan's profile picture

How to you fs.writeLine(text) without deleting the existing text in the file?

Started by Geforce Fan, 29 October 2012 - 09:43 PM
Geforce Fan #1
Posted 29 October 2012 - 10:43 PM
Title says it all.
MysticT #2
Posted 29 October 2012 - 10:51 PM
Open the file in append mode:

local file = fs.open("path/to/file", "a")
if file then
  file.writeLine("some random text")
  file.close()
end
That way it will write to the end of the file, without deleting the previous contents.
Geforce Fan #3
Posted 29 October 2012 - 11:02 PM
Will it add a line?
Ex.
It writes "1"
then later writes "2"
will the file it writes look like
1
2
or will it look like
12
?
MysticT #4
Posted 29 October 2012 - 11:40 PM
If you use writeLine it will be in a new line, if you use write it will be in the same line.