I am asked to show that for $z\in \mathbb{C} \setminus \{0,1\}$, there exists an analytic (single-valued) function, $F(z)$ on $\mathbb{C} \setminus \{0,1\}$, such that $F'=f$, where $$f(z) = \frac{(1-2z)\cos(2\pi z)}{z^2 (1-z)^2}$$ I know that if $$\int_{\gamma} f(z) dz =0$$ for all closed contours, $\gamma$, then $f$ has an antiderivative. Furthermore, in the case of the given function above, $f(z)$, I know that Res$(f,0)=$ Res$(f,1)=0$, so using the Residue Theorem I know that for any simple closed contour, $\gamma$, we have $$\int_{\gamma} f(z) dz =0$$
However, to ensure that $f$ has an antiderivative, I need to show that this is true for all closed $\gamma$, not just simple closed $\gamma$. How can I go about finishing this last step of the proof?
Here is an alternative solution. Write
$$ g(z) = f(z) - \left( \frac{1}{z^2} - \frac{1}{(z-1)^2} \right). $$
Then $g$ has removable singularities at both $z=0$ and $z=1$, and so, $g$ extends to a holomorphic function on $\mathbb{C}$. In particular, $g$ has an antiderivative, say $G(z)$. Then
$$ f(z) = g(z) + \frac{1}{z^2} - \frac{1}{(z-1)^2} $$
has an antideriviative
$$ G(z) - \frac{1}{z} + \frac{1}{z-1}. $$