Support writing state to file