This is Exercise 3.1.13 here.
Let $\gamma:[a,b] \to U \subset\mathbb{C}$ be a piecewise $C^1$, injective (or can also be closed) curve. Show that there exists a continuous function $f$ such that $\int_\gamma f(z)dz \neq 0$.
My idea: Use a bump function $f$ near a point $\gamma(t_0)$ to show $\int_\gamma f(z)dz \approx \gamma'(t_0) l$, where $l$ is the "length of the bump".
Proof: Since $\gamma$ is piecewise $C^1$ and injective, there's $t_0 \in (a,b)$ such that $\gamma'(t_0) \neq 0$. Pick $t_1$ and $t_2$ so that for all $t \in [t_1, t_2]$
$$|\gamma'(t) - \gamma'(t_0)| < \frac{1}{5}|\gamma'(t_0)|.$$
Then let $M=\max _{t \in [t_1, t_2]} |\gamma'(t)| +|\gamma'(t_0)|$ and set $d=\frac{1}{10M}|\gamma'(t_0)|(t_2-t_1)$. Now let's define $f$ so that $f(\gamma(t))=1$ when $t \in [t_1+d, t_2-d]$, $f=0$ outside $t \in [t_1, t_2]$ and on the intervals $[t_1, t_1+d]$, $[t_2-d, t_2]$ $f$ rises and respectively falls linearly (so always $0\leq f \leq 1$). By Tietze, there's a continuous extension of $f$ to $U$ defined on $\gamma([a,b])$ like this. And, since $\gamma$ is injective, this is well defined (we can choose $[t_1, t_2] \subset (a,b)$). Now we can estimate
$$ \left| \int_\gamma f(z)dz - \gamma'(t_0)(t_2-t_1) \right| \\ \leq \int_{t_1}^{t_1+d} |f(\gamma(t))\gamma'(t) - \gamma'(t_0)| + \int_{t_1+d}^{t_2-d} |f(\gamma(t))\gamma'(t) - \gamma'(t_0)| + \int_{t_2-d}^{t_2} |f(\gamma(t))\gamma'(t) - \gamma'(t_0)| \\ \leq dM + \frac{1}{5}|\gamma'(t_0)|(t_2-t_1) + dM \\ = \frac{2}{5}|\gamma'(t_0)|(t_2-t_1) $$
As $I=\int_\gamma f(z)dz$ is closer to $w=\gamma'(t_0)(t_2-t_1)$ than half of $|w|$, $I$ can't be zero.
Question: Is this correct? It feels intuitively true that if there's some part on the curve that isn't exactly canceled (i.e. the curve traces itself back) the curve isn't equivalent to the zero curve. But why does it say that closed $\gamma$ is trickier? I don't see right away how the non-closed case is easier.