Modified fonctions write and read to include fopen and fclose.