Fixed write bug.