improved I/O error handling.