The flawed proof is wrong because of the reason you have given.
The proof in the quoted source is not easily understandable, since the author introduces several "variables", whereby it remains unclear what exactly a "variable" is. The following excerpt from a previous answer of mine implements the proof idea of your source in a (hopefully) more clear way.
We shall make use of the following principle (which works both ways): When the function $g$ is differentiable at $x_0$ then the "trend function"
$$m_{g,x_0}(x):=\cases{{g(x)-g(x_0)\over \mathstrut x-x_0} \quad&$(x\ne x_0)$ \cr \mathstrut g'(x_0)& $(x=x_0)$\cr}$$
is continuous at $x_0$, and one has
$$g(x)-g(x_0)=m_{g,x_0}(x)\cdot(x-x_0)\qquad\forall x\ .$$
When in addition a function $f$ is given which is differentiable at $g(x_0)$ then one can apply said principle to $f$ as well and write
$$\eqalign{f\bigl(g(x)\bigr)-f\bigl(g(x_0)\bigr)&=
m_{f,g(x_0)}\bigl(g(x)\bigr)\cdot \bigl(g(x)-g(x_0)\bigr)\cr
&=m_{f,g(x_0)}\bigl(g(x)\bigr)\cdot\ m_{g,x_0}(x)\cdot(x-x_0)\ .\cr}$$
Since $g$ is continuous at $x_0$ we can conclude that the first two factors on the right hand side make up a function which is continuous at $x_0$ and assumes the value $f'\bigl(g(x_0)\bigr)\>g'(x_0)$ there. The chain rule follows.