91 posts
Posted 28 March 2015 - 04:03 PM
So as i told in topic name, how to make new line of text at the end of file? I need small code.
1140 posts
Location
Kaunas, Lithuania
Posted 28 March 2015 - 04:34 PM
Use the new line character '\n' or use the file.writeLine function, which appends that character automatically.
871 posts
Posted 28 March 2015 - 08:29 PM
note file.writeLine adds a \n to the end, just like print() does, so if you're appending text to an existing log that doesn't have a newline at the end, you'll want to put a '\n' at the start of your string instead. Or just manually repair or reset the log files and always use writeLine instead of write.
1023 posts
Posted 28 March 2015 - 09:35 PM
I am assuming he is talking more about how if you open a file in write mode using fs.open it will erase the contents of the file. So building on what the other people have said you would want to do something like this.
handle = fs.open("file","a") -- "a" stands for append it will add it to the end of the file instead of erasing the file
handle.writeLine("Whatever you want to write here.")
handle.close() -- if you dont close the file it will not save, and other problems could occur.
Edited on 28 March 2015 - 08:37 PM