because I couldn't run the program as sudo within Lazarus with the debugger and that was obviously what was cuasing -1 by FileOpen)
Run it with gdbserver. The stuff that I'm working on either needs POSIX capabilities (which are lost inside gdb) or to be run as root, and using root to run gdbserver then the usual IDE is a combination that works well.
MarkMLl