$\int e^{\sec x} \left(\sec x \tan x f\left(x\right)+\left(\sec x \tan x+\sec^{2}x \right)dx\right) $
$ =e^{\sec x }f\left(x\right)+C $
Diff. both sides w.r.t. 'x'
$ e^{\sec x} \left(\sec x \tan x f\left(x\right) +\left(\sec x \tan x+\sec^{2}x\right)\right) $
$=e^{\sec x}.\sec x \tan x f\left(x\right)+e^{\sec x} f'\left(x\right) $
$ f'\left(x\right) =\sec^{2}x +\tan x \sec x $
$ \Rightarrow f\left(x\right) =\tan x +\sec x +c $