fix write error