STORM-351: fix logic for writing offsets to ZooKeeper

Should be self-explanatory from the diff.