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?

$$a^2 +a\left[b(2-n)\right] + b^2 = 0$$
is a quadratic equation in $a$, so we apply the quadratic formula.  \begin{align*}
a &= \frac{-\left[b(2-n)\right] \pm \sqrt{\left[b(2-n)\right]^2 - 4(1)(b^2)}}{2}  \\
    &= \frac{-b(2-n)}{2} \pm \frac{1}{2}\sqrt{b^2( 4 - 4n + n^2) - 4b^2}  \\
    &= \frac{b}{2}(n-2) \pm \frac{1}{2}\sqrt{b^2( - 4n + n^2)}  \\
    &= \frac{b}{2}(n-2) \pm \frac{1}{2}|b|\sqrt{ n^2 - 4n + 4 - 4}  \\
    &= \frac{b}{2}(n-2) \pm \frac{1}{2}|b|\sqrt{ (n-2)^2 - 4}  \\
    &= \frac{b}{2} \left[ (n-2) \pm \sqrt{ (n-2)^2 - 4}  \right]  \text{,}
\end{align*}
where regardless of the sign of $b$, $\{|b|, -|b|\} = \{b,-b\} $ (in some order), so we get the last line.
We require $a$ is an integer, so the right hand side of this is an integer.  This requires $b[\dots]$ is an even integer (even, to cancel the division by $2$ at the front).  Now $n$ is a known integer, so $(n-2)^2 - 4$ is an integer.  Call this integer
$$  D = (n-2)^2 - 4  \text{.}  $$
If $D$ is a perfect square, $D = d^2$, then 
$$  \frac{b}{2} \left[ (n-2) \pm \sqrt{ D}  \right] = \frac{b}{2} \left[ (n-2) \pm d  \right]  \text{,}  $$
and, excepting the evenness requirement, everything in sight is sums differences and products of integers, so is an integer.
If $D$ is not a perfect square, $\sqrt{D}$ is not an integer; it isn't even a rational number.  So $(n-2) \pm \sqrt{ D}$ is an irrational number, and multiplying by the integer $b$ yields an irrational number.  Dividing by $2$ leaves the number irrational.  But $a$ is rational (it's even an integer), so this cannot be what happens.
