Relock state file when writing.

A recent change to how state file are written caused the statefile lock
to be lost when the file was rewritten. This would have allowed several
Pond clients to be running concurrently with the same statefile and much
badness to occur.