At long last, after tracking down a bug in python-midi, file writing functionality