Alternatively, you can rationalize the denominator by multiplying the numerator and denominator by $(1 - \cos x)$:
\[
\frac{1}{1+\cos x} \cdot \frac{1-\cos x}{1-\cos x} = \frac{1-\cos x}{1-\cos^2 x} = \frac{1-\cos x}{\sin^2 x} = \csc^2 x - \csc x \cot x
\]
Integrating this gives $-\cot x + \csc x + C$, which simplifies exactly to $\tan\left(\frac{x}{2}\right) + C$ using half-angle properties!