Fix short write error