reworked jnx_file_read function to be more standard C compliant