Lua file:read unexpected behavior

Viewed 58

I'm a complete newbie in Lua and i've stumbled upon a problem i don't understand.

So what i'm trying to do is open a file, read the data and save it into a different file with a different name.

Here is the code

local infile = io.open(folder..'/'..f, "r")
local instr = infile:read("*all")
infile:close()

local outfile = io.open(folder..'/'..newName, "w")
outfile:write(instr)
outfile:close()

The result i get is a Source file 288Kb and a Dest file 2Kb

So again, as i'm a newbie in Lua, the fact that the problem is in infile:read is a wild guess for me, but the way i see it, it's either infile:read or outfile:write.

UPD: The content is absolutely arbitrary, which implies special symbols occur.

Thank you in advance,

Regards!

1 Answers
Related