Evaluate the improper integral $\int_0^{\pi/2}(\sec^2x-\sec x \tan x)dx$

Evaluate the improper integral $\int_0^{\pi/2}(\sec^2x-\sec x \tan x)dx$

I got $\int_0^{\pi/2}(\sec^2x-\sec x \tan x)dx=\int_0^{\pi/2} \frac{1-\sin x}{\cos^2x}dx$

The singularity occurs at the point $\pi/2$, but I don't know how to evaluate this integral. I would greatly appreciate any help.

$$\lim_{z\to \pi/2^-}\int_0^z(\sec^2x-\sec x \tan x)\,dx=\lim_{z\to \pi/2^-}[\tan z-\sec z+1]=\lim_{z\to \pi/2^-}\frac{\sin x+\cos x-1}{\cos x}=1$$
Hint: First of all, $~\tan'x=1+\tan^2x=\sec^2x.~$ Secondly, $~\cos'x=-\sin x.$