writeState