[PATCH v2 06/11] Replace FWRITE with a function