Error handling if write failed.