Just keep the file open. I literally this minute have written a logging system for claymore island.
`*************** LOG FILES *****************
function MAIN_StartLog(filename$)
if file exist(filename$)
delete file filename$
endif
open to write 1,filename$
MAIN_AddLog("Log start")
endfunction
function MAIN_EndLog()
MAIN_AddLog("Log end")
GameConfig(0).logcount = 0
close file 1
endfunction
function MAIN_AddLog(message$)
write string 1,str$(GameConfig(0).logcount) + ":" + message$
inc GameConfig(0).logcount,1
endfunction
`*******************************************
Note, GameConfig(0).logcount is a global array. You dont need that. I just used it to add a number to each entry. Just call StartLog, call AddLog anytime you want to add a message and then close it down at the end with EndLog. If your proggy crashes before the endlog command, the file is still written and doesnt cause any problems.