Change fd_write to use fwrite instead of fputc