[PATCH 06/10] Replace FWRITE with a function