Text File Editing

I was wondering if there was a way to be able to write to the next line of text file without overwriting anything there. As I have a list of values and want to add a value to the list.

Use the io module, specifically io.open() then io.write():

The open mode should be "a". For example:

local file = io.open("file.txt", "a")
file:write("Some text output...\nMore text output...")
file:close()

-- file.txt
This line was already here...
So was this one...
Some text output...
More text output...
5 Likes