Need to write some file, then open it for reading and write some lines to another file - all this in one script. My problem is, that I:
open file1 in read mode (file1=io.open("my_file.txt","r"))
open file2 in write mode (file2=io.open("my_changed_file.txt","w"))
write the changed content from file1 to file2
open the file2 (tried also open as file3=io.open("my_changed_file.txt","r")) in read mode and print some lines from it for example
I tried several ways, like file2:flush(), or file2:close() and re-open after I finished writing, but it always returns nil when I want to print some lines
file1=io.open("my_file.txt","r")
file2=io.open("my_changed_file.txt","w")
for line in file1:lines() do
file2:write(line.."changes")
end
file2:flush()
file3=io.open("my_changed_file.txt","r")
--write several lines to another file or something
--(need to combine changed lanes from file2 and original lines from file1 based on my key)