Lemma 31.16.6. Let $X$ be a Noetherian separated scheme. 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$). Each $D_ i \subset X$ has codimension $1$ by Lemma 31.16.5 (and Properties, Lemma 28.10.3). Thus $D_ i$ is an effective Cartier divisor by Lemma 31.15.7. 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).