diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp index 19db0161d..28f839c6c 100644 --- a/src/sound/i_music.cpp +++ b/src/sound/i_music.cpp @@ -803,18 +803,17 @@ CCMD (writemidi) } TArray midi; - FILE *f; bool success; static_cast(currSong)->CreateSMF(midi, 1); - f = fopen(argv[1], "wb"); + auto f = FileWriter::Open(argv[1]); if (f == NULL) { Printf("Could not open %s.\n", argv[1]); return; } - success = (fwrite(&midi[0], 1, midi.Size(), f) == (size_t)midi.Size()); - fclose (f); + success = (f->Write(&midi[0], midi.Size()) == (size_t)midi.Size()); + delete f; if (!success) {