Improved comments. Also read/write binary not text files.