from Second last line, $$\displaystyle \frac{(1+\sin \theta+\cos \theta)^2}{(1+\cos \theta)^2-\sin^2 \theta}=\frac{2\left[1+\sin \theta +\sin \theta\cdot \cos \theta+\sin \theta\right]}{2\cos \theta \cdot (1+\cos \theta)} = \frac{2(1+\cos \theta)(1+\sin \theta)}{2\cos \theta\cdot (1+\cos \theta)}$$
So we get $$\displaystyle \frac{1+\sin \theta}{\cos \theta}$$
Here I have solved Using double angle formula.
Given $\displaystyle \bf{L.H.S}$ as $\displaystyle \frac{1+\cos \theta+\sin \theta}{1+\cos \theta-\sin \theta}$
Let $\theta=2\phi\;,$ Then $$\displaystyle \frac{1+\cos 2\phi+\sin 2\phi }{1+\cos 2\phi-\sin 2\phi} = \frac{2\cos^2 \phi+2\sin \phi\cdot \cos \phi}{2\cos^2 \phi-2\sin \phi\cdot \cos \phi}$$
Above we use the formula $$\bullet \; 1+\cos 2\phi = 2\cos^2 \phi$$
and $$\bullet\; 1-\cos 2\phi = 2\sin^2 \phi$$
and $$\bullet \; \sin 2\phi = 2\sin \phi\cdot \cos \phi$$ and $$\bullet\; \cos^2\phi-\sin^2 \phi = \cos 2\phi$$
So we get $$\displaystyle \frac{\cos \phi+\sin \phi}{\cos \phi-\sin \phi} = \frac{\cos \phi+\sin \phi}{\cos \phi-\sin \phi}\times \frac{\cos \phi+\sin \phi}{\cos \phi+\sin \phi} = \frac{\sin^2 \phi +\cos^2 \phi+\sin 2\phi}{\cos^2 \phi-\sin^2 \phi}$$
So we get $$\displaystyle \frac{1+\sin 2\phi}{\cos 2\phi}$$
Now Put $2\phi = \theta\;,$ We get
$$\displaystyle = \frac{1+\sin \theta}{\cos \theta}$$