do
--read data from file
function readFile()
local fileHandle = assert(io.open("test.txt", "r"), "not the file");
if fileHandle then
local outData = fileHandle:read("*all");
print(outData);
else
print("false");
end
fileHandle:close(errorInfo);
end
--write data to the file
function writeFile(dataBuffer)
local writeHandle = assert(io.open("write.txt", "a+"), "not the file");
if writeHandle then
writeHandle:write(dataBuffer);
print("true");
else
print("false");
end
writeHandle:close();
end
local inputData = 0;
repeat
inputData = io.read(); --write the data from io
writeFile(inputData);
until inputData == '#'
end