Check for error when opening file