Error accessing a file after WriteFile

Blitz3D Forums/Blitz3D Beginners Area/Error accessing a file after WriteFile

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I declared the file handle globally, but still have the same problem

Here is a piece of my code:

Write Function:

filewrite = WriteFile("files\savegame.dat")
If filewrite <> 0 Then ;file exists
;Player info
WriteLine(filewrite,"Player data")
For p.Player = Each Player
WriteLine(filewrite,"LOCX:"+EntityX(p\entity))
WriteLine(filewrite,"LOCY:"+EntityY(p\entity))
Next
EndIf

CloseFile(filewrite)

Read Function:

fileread = OpenFile("files\savegame.dat")

If fileread <> 0 Then ;file exists
While Not Eof(fileread)
fr1$=ReadLine( fileread )

line_int%=Instr(fr1,"LOCX:",1)
If line_int <> 0 Then
strcount=5
s$=Mid(fr1,line_Int+strcount,10) : pfx=s
EndIf

line_int%=Instr(fr1,"LOCY:",1)
If line_int <> 0 Then
strcount=5
s$=Mid(fr1,line_Int+strcount,10) : pfy=s
EndIf

line_int%=Instr(fr1,"LOCZ:",1)
If line_int <> 0 Then
strcount=5
s$=Mid(fr1,line_Int+strcount,10) : pfz=s
EndIf
Wend
EndIf

CloseFile(fileread)

Thanks for your replies..