I am unfamilier with all of lua's syntax, so I am not certain that it's ok in those examples I gave.
But since it's complaining about nil, I'm not convinced that it just isn't finding the file.
Here are some examples of file opening on the unofficial FAQ:
http://www.luafaq.org/#T2.3
using the simple and complete model for handling files.
My instinct tells me the code from your OP is correct, but needs more path.
As much of a hassle mungeing and testing is, perhaps try a barrage of paths till one works.
Or try putting a copy of the file in every folder to see if the code you have finds one of them.
If the last one works without error, then rewrite the code so that it writes something to the file, so you can go find the changed one and know what it considers root for pathing.
Typically, lua looks in the directory the script was run from. In the case of our hosted scripting environment, that would be the place where the exe is located.
(Lua4 has none of all the io. stuff. Blessing and a curse, I suppose.)