Fixed file write, the frame count was not being written correctly to the file.