Fix bug: output file didn't include last byte.