Check for error when calling open()