Problem with my read file function

i am writing a game that requires a high score to be saved. everything else in the game is tested on an android device and works fine. the only problem i am  having is with the read() function. iv determined this by commenting out sections of code and pinpointing the exact line that makes it crash. to me make it more difficult it works fine in the simulator it just crashes on the actual phone. here is the section that is making it crash

local path = system.pathForFile( “HIGHSCORE.txt”, system.DocumentsDirectory )

local file = io.open( path, “r” )

local displayhighscore = file:read("*n") 

am i doing anything wrong in the read("*n") part? any help would be greatly appreciated, 

thanks!

Have you made sure that the file actually exists in the projects sandbox ?

Also put an if statement after you declare file to check to see if file nil/exists [lua]local file = io.open( path, “r” )

if not file then

            – if file aint exist then …

         print(“No file/savefile exists yet for this game”)

            return

           

        end[/lua]

If file does exists check that the filenames match.

Edit: What file format are you using ? i.e JSON

GL

Simon

the format is just a plain text doc. which format would you recommend?

Have you made sure that the file actually exists in the projects sandbox ?

Also put an if statement after you declare file to check to see if file nil/exists [lua]local file = io.open( path, “r” )

if not file then

            – if file aint exist then …

         print(“No file/savefile exists yet for this game”)

            return

           

        end[/lua]

If file does exists check that the filenames match.

Edit: What file format are you using ? i.e JSON

GL

Simon

the format is just a plain text doc. which format would you recommend?