First draft of handling errors from read and write calls.