Back! This code isn't writing in the second file… Have fun, I should start a daily code fix challenge!
function fileExec(path,file,path2,file2)
local path = fs.combine(path, file)
local path2 = fs.combine(path2,file2)
if fs.exists(path) then
local fileHandle = fs.open(path, "r")
local fileData = {}
if fileHandle then
repeat
line = fileHandle.readLine()
table.insert(fileData, line)
until line == nil
fileHandle.close()
local fileHandle2 = fs.open(path2,"w")
if filehandle2 then
data = 1
repeat
fileHandle2.writeLine(fileData[data])
data = data +1
until (fileData[data] == nil)
fileHandle2.close()
else
return nil, "Error opening file!"
end
else
return nil, "Error opening file!"
end
else
return nil, "File not found!"
end
end
EDIT:
FIXED CODE:
function fileExtract(path,file,path2,file2)
local path3 = path2
local file3 = file2
local path = fs.combine(path, file)
local path2 = fs.combine(path2,file2)
if fs.exists(path) then
local fileHandle = fs.open(path, "r")
local fileData = {}
if fileHandle then
repeat
line = fileHandle.readLine()
table.insert(fileData, line)
until line == nil
fileHandle.close()
local fileHandle2 = fs.open(path2,"w")
if fileHandle2 then
data = 1
repeat
fileHandle2.writeLine(fileData[data])
data = data +1
until (fileData[data] == nil)
fileHandle2.close()
else
return nil, "Error opening file!"
end
else
return nil, "Error opening file!"
end
else
return nil, "File not found!"
end
end