Let $k$ be an algebraically closed field. Consider the Zariski-closed subset $Y=Z(xw-yz)\subset k^n$. On $U=Y\setminus Z(y,w)$ we consider the function
$$
f\colon U\to k, P=(a,b,c,d)\mapsto 
\begin{cases}
a/b &\text{if $P\in U\setminus Z(y)$,}\\
c/d & \text{if $P\in U\setminus Z(w).$}
\end{cases}
$$
My lectures notes claim that this is an example of a function that cannot be written as $f=g/h$ for $f,g\in k[x,y,z,w]$. I haven't been able to actually prove this. What I checked was that $xw-yz$ is an irreducible polynomial, and hence $Z(xw-yz)$ is irreducible. This would mean that if there were $g,h\in k[x,y,z,w]$, then $x/y=f/g$ on $U\setminus Z(y)$, and hence $xg=yf$ (since $U$ is also irreducible). Likewise $z/w=f/g$ yields $zg=wf$ on $U$. I can't find a contraction using this, which I need. Could someone help me out?

This question has been asked before (e.g. here: [An example of a regular function over an open set](https://math.stackexchange.com/questions/149688/an-example-of-a-regular-function-over-an-open-set/149797#149797)), but the accepted answer talks about Cartier divisors, which I haven't seen before, so I'm actually hoping there is a more elementary argument.