Whenever I see a
$\cos(kx)$ or
$\sin(kx)$
I automatically think of
the real or imaginary part
of $e^{-kx}$.
So, let
$f(x)
=\sum_{k=1}^{\infty} \frac{e^{ikx}}{k}
$.
$f'(x)
=\sum_{k=1}^{\infty} ie^{ikx}
=\frac{ie^{ix}}{1-e^{ix}}
$.
At this stage,
I try to integrate
$\frac{e^{ax}}{1-e^{ax}}$,
so that I can later
set $a = i$.
Being lazy,
I throw it at
Wolfram's integrator
and get
$\frac{-\ln(e^{ax}-1)}{a}
$.
I check that
yes,
this is correct.
Putting $a=i$,
I get
$\int \frac{ie^{ix}dx}{1-e^{ix}}
=\frac{-i\ln(e^{-ix}-1)}{i}
=-\ln(e^{-ix}-1)
$.
Looking at that result,
I get annoyed at myself
for not immediately using
$-\ln(1-x)
=\sum_{k=1}^{\infty} \frac{x^k}{k}
$.
At this point,
I stop and
give this to you to finish,
leaving you the task
of getting the $\ln$
of that complex expression
and separating the
real and imaginary parts.