Don't rely on exceptions for control flow
Consistenly open the state file in binary mode