I am trying to solve Exercise 3.15 in Gathmann's 2014 notes. Given an irreducible affine variety $X$ such that $A(X)$ is UFD und $U$ like in the heading I want to show that the sheaf of regular functions on $U$ is already the whole coordinate ring $A(X)$.
From a previous exercise I know that regular functions on $U$ are given as a quotient of polynomials globally on $U$ if $A(X)$ is UFD i.e. $\varphi(x) = \frac{g(x)}{f(x)}$ for all $x \in U$ and $f,g \in A(X)$. It seems reasonable to show that $f$ is a unit using the fact that this equation kind of holds in dimension $2$ but I have no idea how to proceed at this point.