Reputation: 1610
So I'm trying to make my first lua program and I can't figure out why when I read in a file it returns that the file doesn't exist or isn't in the directory...here's my code.
io.input("myfile.txt")
word = io.read("*line")
print (word)
myfile.txt is in the same directory as the project....what could possibly be wrong?
Upvotes: 1
Views: 571
Reputation: 202505
I can't duplicate this problem:
: nr@homedog 10317 ; echo foo > myfile.txt
: nr@homedog 10318 ; lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> io.input("myfile.txt")
> word = io.read("*line")
> print (word)
foo
>
Upvotes: 1