Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7823221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:10:21+00:00 2026-06-02T08:10:21+00:00

I am sorry for a duplicate post or something. I am just trying to

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:10:22+00:00Added an answer on June 2, 2026 at 8:10 am

    Your code is ok, except for the file closing part:

         file = io.open(filename, "r")
         if file == nil then
              return false
         else
              file.close(file)
              return true
    

    Do you really have the file myFile.txt in current directory?

    %ls -l
    -rwxr--r--  1 aef  wheel  324 23 апр 10:24 a.lua
    -rw-r--r--  1 aef  wheel    0 23 апр 10:16 myFile.txt
    %lua-5.1 a.lua
    Hello
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this is a duplicate question...I've searched around and found similar advice but
sorry if it's duplicate, I've been looking for something similar before posting, but no
Possible Duplicate: What is the !! operator in JavaScript? Sorry if this one is
sorry if this is a duplicate to one of existing questions (it's so simple
Sorry if this is duplicate,I would think it would be but couldn't find anything.
Sorry if this is a duplicate - couldn't find an answer by searching. How
Sorry, if this is a duplicate. Please point me to the appropriate question if
I am sorry if this is a duplicate but I was not able to
I am sorry if this is a duplicate or too elementary, but how do
I'm sorry if this is a duplicate, but the question search terms are pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.