Fix write error