$K$ is an algebraically-closed field, and for an affine variety $X$, $A(X) $ denotes the ring of polynomial functions on $X$.
What I would like to prove is the following:
"Let $X \subset \Bbb{A}^n(K) $ be Zariski-closed, and $ f: X \rightarrow K $ be regular; that is, for each $x \in X$ there's a neighbourhood $U_x $ containing $x$ and $g,h \in A(X)$, with $h$ nonzero on $U_x$ and $f = g/h$ on $U_x$. Then, $f \in A(X) $."
I've seen and understood a proof in the case where $X$ is irreducible, and I've also seen this thread - Does a regular function on an affine variety lie in the coordinate ring?(Lemma 2.1, Joe Harris) - where I agree with them that the proof in Harris fails at the penultimate line; but I didn't understand what was said in the answer (or indeed most of what was said in the question). What I'd like is if someone could give me a proof, or a link to a proof, of the general theorem; or could explain the answer in that other thread.
I've looked around the web for such a proof, but just can't find one. I'm halfway through a first course in algebraic geometry, so don't know about schemes, sheaves etc. but am fine with localisation and other undergrad (basic level grad?) commutative algebra. Thanks so much in advance!