using fopen and fwrite functions