Generalizing the exception handling and using the Exception type class instead of particular IOError type.