Lemma 31.16.7. Let $X$ be a Noetherian scheme with affine diagonal. Let $U \subset X$ be a dense affine open. If $\mathcal{O}_{X, x}$ is a UFD for all $x \in X \setminus U$, then there exists an effective Cartier divisor $D \subset X$ with $U = X \setminus D$.

Proof. Since $X$ is Noetherian, the complement $X \setminus U$ has finitely many irreducible components $D_1, \ldots , D_ r$ (Properties, Lemma 28.5.7 applied to the reduced induced subscheme structure on $X \setminus U$). We view $D_ i$ as a reduced closed subscheme of $X$. Let $X = \bigcup _{j \in J} X_ j$ be an affine open covering of $X$. For all $j$ in $J$, set $U_ j = U \cap X_ j$. Since $X$ has affine diagonal, the scheme

$U_ j = X \times _{(X \times X)} (U \times X_ j)$

is affine. Therefore, as $X_ j$ is separated, it follows from Lemma 31.16.6 and its proof that for all $j \in J$ and $1 \leq i \leq r$ the intersection $D_ i \cap X_ j$ is either empty or an effective Cartier divisor in $X_ j$. Thus $D_ i \subset X$ is an effective Cartier divisor (as this is a local property). Hence we can take $D = D_1 + \ldots + D_ r$. $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).