I am sorry for a duplicate post or something. I am just trying to confirm this one because I have seen similar post and did the same yet my output is not what i wanted to be the problem is to read a text file in Lua language. Here’s my code:
function fileExists(filename)
file = io.open(filename, "r")
if file == nil then
return false
else
return true
end
end
if fileExists ("myFile.txt") then
print ("Hello")
else
print("not found")
end
It keeps returning false and print not found. And also am trying to open a .lrc file instead of .txt. What is wrong with that simple, little lines of code?
Your code is ok, except for the file closing part:
Do you really have the file
myFile.txtin current directory?