Reorganize Read/Write logs a bit

This separates out the binary protocol logic from file reading and
writing, making it easier to test.