You got the difference $\infty - \infty$ and you set it equal to $0$, but this difference is undefined.

Using Euler's formula $$e^{ix}=\cos{(x)}+i \sin{(x)}$$

we get $$\cos{(x)}=\frac{e^{ix}+e^{-ix}}{2}$$

Therefore we have the following:

$$\int_{0}^{\infty} \frac{cos(kx)}{k}\,dk- \int_{0}^{\infty} \frac{e^{-2k}cos(kx)}{k}\,dk =\int_{0}^{\infty} \frac{e^{ikx}+e^{-ikx}}{2k}\,dk -\int_{0}^{\infty} \frac{e^{-2k}(e^{ikx}+e^{-ikx})}{2k}\,dk= \\ \int_{0}^{\infty} \frac{e^{ikx}+e^{-ikx}}{2k}\,dk -\int_{0}^{\infty} \frac{e^{(ix-2)k}+e^{-(ix+2)k}}{2k}\,dk$$