Error processing modified around write() call