What's wrong in my calculation of $\int \frac{\sin x}{1 + \sin x} dx$? I have the following function:
$$f: \bigg ( - \dfrac{\pi}{2}, \dfrac{\pi}{2} \bigg ) \rightarrow \mathbb{R} \hspace{2cm} f(x) = \dfrac{\sin x}{1 + \sin x}$$
And I have to find $\displaystyle\int f(x) dx $. This is what I did:
$$\int \dfrac{\sin x}{1 + \sin x}dx=
\int \dfrac{1+ \sin x - 1}{1 + \sin x}dx =
\int dx - \int \dfrac{1}{1 + \sin x}dx = 
$$
$$ = x - \int \dfrac{1 - \sin x}{(1 + \sin x)(1 - \sin x)} dx$$
$$= x - \int \dfrac{1 - \sin x}{1 - \sin ^2 x} dx$$
$$= x - \int \dfrac{1 - \sin x}{\cos^2 x} dx$$
$$= x - \int \dfrac{1}{\cos^2x}dx + \int \dfrac{\sin x}{\cos^2 x}dx$$
$$= x - \tan x + \int \dfrac{\sin x}{\cos^2 x}dx$$
Let $u = \cos x$
$du = - \sin x dx$
$$=x - \tan x  - \int \dfrac{1}{u^2}du$$
$$= x - \tan x  + \dfrac{1}{u} + C$$
$$= x - \tan x + \dfrac{1}{\cos x} + C$$
The problem is that the options given in my textbook are the following:
A. $x + \tan {\dfrac{x}{2}} + C$
B. $\dfrac{1}{1 + \tan{\frac{x}{2}}} + C$
C. $x + 2\tan{\dfrac{x}{2}} + C$
D. $\dfrac{2}{1 + \tan{\frac{x}{2}}} + C$
E. $x + \dfrac{2}{1 + \tan{\frac{x}{2}}} + C$
None of them are the answer I got solving this integral. What is the mistake that I made and how can I find the right answer? By what I've been reading online, you can get different answers by solving an integral in different ways and all of them are considered correct. They differ by the constant $C$. I understand that, but I don't see how to solve this integral in such a way to get an answer among the given $5$. And, even more importantly, how can I recognize the right answer in exam conditions if the answer provided by my solution is not present among the given options? Is solving in a different manner my only hope?

Required answer is $E$. Observe that
$$\frac{1}{\cos x}-\tan x=\frac{1-\sin x}{\cos x}$$
$$=\frac{(\cos\frac{x}{2}-\sin\frac{x}{2})^2}{\cos^2\frac{x}{2}-\sin^2\frac{x}{2}}$$
$$=\frac{\cos\frac{x}{2}-\sin\frac{x}{2}}{\cos\frac{x}{2}+\sin\frac{x}{2}}$$
$$=\frac{1-\tan\frac{x}{2}}{1+\tan\frac{x}{2}}$$
$$=\frac{2}{1+\tan\frac{x}{2}}-1$$
Also, note that you could have directly got this answer if you have integrated $\frac{1}{1+\sin x}$ in a different manner, as follows.
$$\int\frac{1}{1+\sin x}dx=\int\frac{1}{(\cos\frac{x}{2}+\sin\frac{x}{2})^2}dx$$
$$=\int \frac{1}{\cos^2\frac{x}{2}(1+\tan\frac{x}{2})^2}dx$$
Now substitute $\tan\frac{x}{2}$ and you are done.
