Catch IO errors in try block.