Here is example that creates test.txt file and writes numbers from 1 to 10 to it. Every time you run it again, it add next ten numbers to the file.
if (fileexists("test.txt") == false) then
plik = open("test.txt", "w")
for x = 1, 10 do
fprint(plik, x)
end
close(plik)
end
plik = open("test.txt", "r")
x = 0
while (eof(plik) == false) do
x = x + 1
finput(plik)
end
close(plik)
plik = open("test.txt", "a")
for y = x + 1, x + 10 do
fprint(plik, y)
end
close(plik)