So a while ago I saw a proof of the Completeness Theorem, and the hard part of it (all logically valid formulae have a proof) went thusly:
Take a theory $K$ as your base theory. Suppose $\varphi$ is logically valid but not a theorem. Then you can add $\neg\varphi$ to $K$'s axioms, forming a new theory $K'$ which is consistent, and therefore $K'$ has a model $M$. Since $\neg\varphi$ is an axiom of $K'$, $M\models\neg\varphi$, but since $\varphi$ is logically valid in $K$ and $M$ is also a model of $K$, $M\models\varphi$, contradiction. Therefore, $\varphi$ must be a theorem of $K$.
Which makes sense to me, but I don't see how the above fails in second-order logic? This theorem looks perfectly generalisable to second-order logic, I don't see any steps that couldn't be done there.
Is the theorem correct? If not, why? If so, which part fails in second-order logic?
As was commented, I got three isomorphic answers, and I can't set all of them as the true answer so I set the one that was phrased in the clearest way to me. In any case, thank you all!