fixed write error