fix session file write bug