[guided]The point of the preceding step was to obtain identities that hold at every point of $X$, not just on one member of the cover. For each $i\in\{1,\dots,r\}$, we have a polynomial $H_i\in R$ and an integer $N_i\ge 1$ such that
\begin{align*}
g_i(q)^{N_i}f(q)=H_i(q)
\end{align*}
for every $q\in X$.
Now we need coefficients that add the functions $g_i^{N_i}$ to $1$ on $X$. Since $D_X(g_1),\dots,D_X(g_r)$ cover $X$, there is no point of $X$ at which all $g_i$ vanish. Equivalently, there is no point of $X$ at which all powers $g_i^{N_i}$ vanish, so
\begin{align*}
V_X(g_1^{N_1},\dots,g_r^{N_r})=\varnothing.
\end{align*}
By [citetheorem:9414], the ideal of functions vanishing on this empty closed set has radical equal to the whole coordinate ring. Therefore
\begin{align*}
1\in \sqrt{(\overline{g_1}^{N_1},\dots,\overline{g_r}^{N_r})}\subseteq k[X].
\end{align*}
Unpacking radical membership, there is an integer $m\ge 1$ such that $1^m$ belongs to the ideal $(\overline{g_1}^{N_1},\dots,\overline{g_r}^{N_r})$. Since $1^m=1$, we get
\begin{align*}
1\in (\overline{g_1}^{N_1},\dots,\overline{g_r}^{N_r}).
\end{align*}
Thus there exist polynomials $E_1,\dots,E_r\in R$ such that, in $k[X]$,
\begin{align*}
1=\sum_{i=1}^r \overline{E_i}\,\overline{g_i}^{N_i}.
\end{align*}
Define
\begin{align*}
F:=\sum_{i=1}^r E_iH_i\in R.
\end{align*}
Evaluating the coordinate-ring identity at any point $q\in X$ gives
\begin{align*}
1=\sum_{i=1}^r E_i(q)g_i(q)^{N_i}.
\end{align*}
Multiplying by $f(q)$ and then substituting the global identities $g_i(q)^{N_i}f(q)=H_i(q)$ gives
\begin{align*}
f(q)=\sum_{i=1}^r E_i(q)g_i(q)^{N_i}f(q)=\sum_{i=1}^r E_i(q)H_i(q)=F(q).
\end{align*}
Since $q\in X$ was arbitrary, the regular function $f$ is the restriction to $X$ of the ambient polynomial $F$.[/guided]