I am trying to

verify that $\displaystyle\int_0^{2\pi} \frac{d\theta}{1+a\cos(\theta)} = \frac{2\pi}{\sqrt{1-a^2}}$, for $-1\lt a \lt 1$.

So far I replaced $\cos(\theta)$ with $\dfrac{z+\frac{1}{z}}{2}$ and $d\theta$ with $\dfrac{dz}{iz}$, and then simplified to get $$\frac 2 i \int_C \frac{dz}{az^2+2z+a}$$ (with $C$ being the unit circle). Then this function will have simple poles at $\frac{-1\pm\sqrt{1-a^2}}{a}$. Then I calculated $\operatorname{Res}\left(f: \dfrac{-1+\sqrt{1-a^2}} a\right) = \dfrac a {2\sqrt{1-a^2}}$ and $\operatorname{Res}\left(f: \dfrac{-1-\sqrt{1-a^2}} a \right) = \dfrac{-a}{2\sqrt{1-a^2}}$. But then when I apply the residue theorem, clearly the sum of the two residues is zero, and then the entire integral is zero. I'm sure there must be a mistake in my calculations somewhere, but I'm not sure where. I'm thinking maybe I need to use that a is between $-1$ and $1$. Any help/corrections are appreciated!