amended fwrite