added fread and fwrite