Diophantine equation from "Solving mathematical problems" by Terence Tao 
Find all integers $n$ such that the equation $\frac{1}{a} + \frac{1}{b} = \frac{n}{a+b}$ is satisfied for some non-zero values of  $a$ and $b$ (with $a + b \neq 0$).

I'm reading "Solving mathematical problems" by Terence Tao and I'm a bit stuck on this particular example. It starts as follows:
First multiplying out the denominators we get
$$\frac{a+b}{ab} = \frac{n}{a+b}$$
and from here follows $$(a+b)^2 = nab.$$
Now expanding this we get
$$a^2+2ab+b^2-nab=0 \Leftrightarrow a²+ab(2-n)+b^2.$$
From here on he suggests to use the quadratic formula to get
$$a= \frac{b}{2}[(n-2) \pm \sqrt{(n-2)^2-4}]$$
which I don't quite see how he came up with...
Also he then notes that "This looks very messy, but actually we can turn this messiness to our advantage. We know that $a, b$, and $n$ are integers, but there is a square root in the formula. Now this can only work if the term inside the square root, $(n-2)^2-4$ is a perfect square."
Could someone enlighten me on the part "Now this can only work if the term inside the square root, $(n-2)^2-4$ is a perfect square." what is he stating right here?

The author finds the identity
$$a= \frac{b}{2}[(n-2) \pm \sqrt{(n-2)^2-4}],$$
by applying the quadratic formula to the previous equation, which is a quadratic in $a$:
$$a^2+b(2-n)\cdot a+b^2=0.$$
Plugging the coefficients into the quadratic formula yields
\begin{eqnarray*}
a&=&\frac{-b(2-n)\pm\sqrt{(b(2-n))^2-4b^2}}{2}\\
&=&\frac{b(n-2)\pm\sqrt{(4b^2-4b^2n+b^2n^2)-4b^2}}{2}\\
&=&\frac{b(n-2)\pm\sqrt{b^2n^2-4b^2n}}{2}\\
&=&\frac{b(n-2)\pm|b|\sqrt{n^2-4n}}{2}\\
&=&\frac{b(n-2)\pm b\sqrt{(n-2)^2-4}}{2}\\
&=&\frac{b}{2}\Big((n-2)\pm\sqrt{(n-2)^2-4}\Big).
\end{eqnarray*}
Next, you can rewrite the equality
$$a= \frac{b}{2}[(n-2) \pm \sqrt{(n-2)^2-4}],$$
to isolate the square root. You will find that
$$\sqrt{(n-2)^2-4}=\pm\Big(2a-b(n-2)\Big).$$
Because $a$, $b$ and $n$ are integers, the right hand side is an integer. This means the term inside the square root is a perfect square; it means
$$(n-2)^2-4=\Big(2a-b(n-2)\Big)^2.$$

As a side note, the questions can be solved with far fewer computations by noting that
$$(a+b)^2=nab,$$
implies that $a$ divides $b$ and $b$ divides $a$, so $b=\pm a$. Because $a+b\neq0$ this means $a=b$ and the equation above becomes
$$na^2=(a+a)^2=4a^2,$$
which shows that $n=4$ because $a$ is nonzero.
