Yes, some systems do have an end-of-file character. MS-DOS used the ^Z (b'\x1a') in text files to signify the end of file. If the file was opened in binary mode, this wouldn't be the case. In UNIX, the ^D (b'\x04') (can be used on terminal to signify the end-of-file for...
I fixed the issue as follows: bytestream = io.BytesIO() midi.writeFile(bytestream) temp = io.BytesIO(bytestream.getvalue()) pygame.mixer.music.load(temp) As it seems, the writeFile() operation somehow makes the BytesIO object invalid to the pygame.mixer.music.load() method. By using the constructor of BytesIO again with the correctly created bytestream we magically get a valid bytestream we can...