fix source code to use freadf and fwritef.