We tried to do an integral with the universal trigonometric substitution $$\int \frac{1}{(1+\sin x)}\, \mathrm dx$$
Meaning, we substituted: $ t = \tan \frac{x}{2} \Rightarrow$
$$\int \frac{1}{(1+\sin x)}\, \mathrm dx = \int \frac{\frac{2}{1+t^2}}{1+\frac{2t}{1+t^2}}\, \mathrm dt = \int \frac{2}{(1+t)^2}\, \mathrm dt = \frac{-2}{1+t} = \frac{-2}{1+\tan \frac{x}{2}} + C$$
But the answer is: $$ \tan x - \frac{1}{\cos x} + C $$
What did we do wrong?