Tested code for r/w. Put fread and fwrite.