modified readBinaryFile to close the output file