Stalks, Germs and Localisation

I've been trying to prove the following proposition:

Let $$(X,\mathcal{O}_X)$$ be a quasi-compact ringed space which is locally isomorphic to an affine variety over an algebraically closed field $$k$$.

Let $$x\in X$$ and $$U\subseteq X$$ be an affine open set of $$X$$ with $$x\in U$$. Then for $$A=\Gamma(U,\mathcal{O}_X)$$ with maximal ideal $$m=\{f\in A\mid f(x)=0\}$$, we have $$A_m\cong\mathcal{O}_{X,x}$$, the stalk of $$\mathcal{O}_X$$ at $$x$$.

I've can prove the case where $$U$$ is irreducible:

We have $$A_m=\{\frac{f}{g}\mid f,g\in\Gamma(U,\mathcal{O}_X),g(x)\neq0\}$$. Let $$\varphi:A_m\to\mathcal{O}_{X,x}$$ send $$\frac{f}{g}$$ to the germ $$(D(g),\frac{f}{g})$$.

To show that $$\varphi$$ is surjective, take any $$(H,h)\in\mathcal{O}_{X,x}$$, where $$H\subseteq X$$ is open, $$x\in H$$ and $$h\in\Gamma(H,\mathcal{O}_X)$$. We have $$H\cap U=\cup_{i=1}^nD(g_i)$$ for some $$g_i\in\Gamma(U,\mathcal{O}_X)$$, with $$h\mid_{D(g_i)}=\frac{f_i}{g_i}\mid_{D(g_i)}$$ for some $$f_i\in\Gamma(U,\mathcal{O}_X)$$. Then $$(H,h)=(D(g_1),\frac{f_1}{g_1})=\varphi(\frac{f_1}{g_1})$$ since $$h$$ and $$\frac{f_1}{g_1}$$ agree on $$\cap_{i=1}^nD(g_i)$$, which is non-empty since $$U$$ is irreducible.

For injectivity, if we have $$\varphi(\frac{f_1}{g_1})=\varphi(\frac{f_2}{g_2})$$, then we know that $$\frac{f_1}{g_1}$$ and $$\frac{f_2}{g_2}$$ agree on some non-empty open $$W\subseteq D(g_1)\cap D(g_2)$$. Then $$W\subseteq V(f_1g_2-f_2g_1)$$, so by the irreducibility of $$U$$ we have that $$f_1g_2=f_2g_1$$ on all of $$U$$, so $$\frac{f_1}{g_1}=\frac{f_2}{g_2}$$ in $$A_m$$.

However this argument makes heavy use of the irreducibility of $$U$$, and I can't seem to generalise it to the case where $$U$$ might not be irreducible.

For surjectivity, we know there exist some $$f,g\in\Gamma(U,\mathcal{O}_X)$$ such that $$x\in D(g)\subseteq H\cap U$$ and $$h\vert_{D(g)}=\frac{f}{g}\vert_{D(g)}$$, and so $$\varphi(\frac{f}{g})=(H,h)$$, we don't need to mess around with the full cover.
For injectivity, since $$\frac{f_1}{g_1}$$ and $$\frac{f_2}{g_2}$$ agree on some open $$W\subseteq D(g_1)\cap D(g_2)$$, we know they agree on some $$D(h)\subseteq W$$ with $$h\in\Gamma(U,\mathcal{O}_X)$$ and $$x\in D(h)$$. Then $$f_1g_2-f_2g_1$$ on $$D(h)$$, so $$h(f_1g_2-f_2g_1)=0$$ everywhere. Since $$h(x)\neq0$$ we have $$h\notin m$$, so this shows that $$\frac{f_1}{g_1}=\frac{f_2}{g_2}$$ in $$A_m$$.