Fix bug in cpp version where binary file input done incorrectly.