If $\frac{z-a}{z+a},a\in \mathbb{R}$ is a purely imaginary number and $|z|=2$, then a value of a is ___. (JEE Main 2019)
For a purely imaginary number $w$, we must have $w+\bar{w}=0$, giving us $a=2$. (This solution is standard substitution and simplification, resulting in a quadratic).
I tried it using a different method(below): $$\frac{z-a}{z+a}\times\frac{\bar{z}-a}{\bar{z}-a}=\frac{z\bar{z}-az-a\bar{z}+a^2}{z\bar{z}-a^2}=\frac{z\bar{z}-az-a\bar{z}+a^2}{|z|^2-a^2}=\frac{z\bar{z}-az-a\bar{z}+a^2}{4-a^2}$$ where in the last step we substituted $z\bar{z}=|z|^2=4, z+\bar{z}=0$$
The denominator of this expression (from the other, valid solution is zero), and hence the expression is not defined.
What was the mistake and at what step was it made?