fix writeError