Catching IOError instead of integers and checking the errno on the IOError for the same error codes