Here is my code that reads wave files: [https://github.com/treeform/euphony/blob/master/src/euphony/wav.nim](https://github.com/treeform/euphony/blob/master/src/euphony/wav.nim)
There i use newFileStream which makes reading binary files really easy. Just use readStr, readUint16, readUint32... Wave happens to be a really easy format to read. Just a small header and big chunk of data. If you also want to play files use the rest of the sound library for that: [https://github.com/treeform/euphony](https://github.com/treeform/euphony) Note: Your code should also work with the readBuffer but I think you opened the file for writing with FileMode.fmWrite.
