All fixed. To anyone who stumbles across this with the same problems: 1) global variables need to be defined in the procedure as well as outside the proc. 2) file id's can be defined globally by doing: PHP Code: global int $file; $file = `fopen $fileLoc "r"`;