Jump to content




New lines in writing to files


  • You cannot reply to this topic
1 reply to this topic

#1 mrpoopy345

  • Members
  • 148 posts
  • LocationMy Computer

Posted 16 December 2013 - 05:36 PM

Hello! I need help. What I want to do is open a file and write a variable to it in a new line of the program.
For ex:
File before I write to it:
Hello
File after I write to it:
Hello
World
Any help?

#2 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 16 December 2013 - 06:00 PM

Do you mean the append mode?
--# Creating the file and clearing it if it exists
local file = fs.open("<file>", "w")
file.write("Hello")
file.close()

--# Opening and adding the new data without clearing the file
local file = fs.open("<file>","a")
file.writeLine("World") -- writes to a newline
file.close()

Check out the wiki about fs.open for more information

Edited by Hellkid98, 16 December 2013 - 06:02 PM.






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users