openfile is a stock function that only reads in the scriptdata directory.
You should look into the fopen, fread and fclose functions.
The documentation is missing these functions.
...