if you are creating the file it doesn't really matter what extension you give it as the data put in will be managed by you (in most cases this will be human-readable string)
it's pretty straight forward, just need to know the arguments for the operations (i.e. if you want to overwrite or append etc)
to write to a file
--open a file to write to ("w" mode should make a new file if it doesn't exist)
file = io.open("myfile.dat", "w")
io.output(file)
--the actual data you want to write ("\n" makes a new line after)
io.write(variable1.. "\n")
--you can do this part multiple times if you want to break the data up
--eg
io.write(variable2 .. "\n")
--close your file so it saves and you can open it again later etc
io.close(file)
now you can access your file using a similar method
--the file you want to open to read from ("r" means read mode)
file = io.open("myfile.dat", "r")
--good idea to check the file exists before getting data from it
if file ~= nil then
io.input(file)
--to read each line use "*line" or to read the whole file use "*all" or nothing
--so to read our saved file with 2 lines getting them individually we could use
value1 = io.read("*line")
value2 = io.read("*line")
io.close(file)
end