Why must $\int_\gamma f(z)\;d z = 0$ for *any* contour $γ$ to define antiderivative of $f$? Whilst I was reading the following proposition from Dexter Chua's lecture notes on Complex Analysis:

Let $U \subseteq \mathbb{C}$ be a domain (i.e. path-connected non-empty open set), and $f: U \to \mathbb{C}$ be continuous. Moreover, suppose
$$
    \int_\gamma f(z)\;d z = 0
  $$
for any closed piecewise $C^1$-smooth path $\gamma$ in $U$. Then $f$ has an antiderivative.

I am not sure where in the proof does use the property that the integral must vanish on a closed path except at its well-definedness.
Sketch Proof:
Pick any point $a_0\in U$ and let $\gamma_w$ be any path from $a_0$ to $w.$
Define $F(w) = \int_{\gamma_w} f(z)\;d z,$ we will show it is an antiderivative, now use the hypothesis that the integral around a closed path must vanishes shows that such $F(w)$ is independent of the path chosen.
Since $U$ is open, we can pick $\epsilon > 0$ such that $B(w; \varepsilon) \subseteq U$. Let $\delta_h$ be the radial path in $B(w, \varepsilon)$ from $w$ to $w + h$, with $|h| < \varepsilon$. Now note that $\gamma_w * \delta_h$ is a path from $a_0$ to $w + h$. Now we can show, $$\left|\frac{F(w+h)-F(w)}{h}-f(w)\right|\to 0$$ as $h\to 0$
[I have skipped a great detail of the proof, the full proof can be found here. Page 22]
My confusion:
Why do we need $F$ to be independent on the path taken? Why can we not have the situation where each path will yield a different anti-derivative?
Moreover suppose the definition of $F(w)$ does depend on the path taken (and so different path gives different $F$), would it not be true that for each path $\gamma_i$, the induced $F_{\gamma_i}(z)$ will have the property that $F_{\gamma_i}'(z)=f(z)$, simply because the above limit, where $h\to 0$ will still stand?
(I know this will not be true since if this is true then any continuous function will have an anti-derivative but I cannot seem to see where, other than well-defineness, does it use the integral must vanish property.)
Many thanks in advance!
 A: You can choose a path $\gamma_w$ for each $w$ and define $F(w) = \int_{\gamma_w} f$, but there's no guarantee without the assumption in the proposition that the result will even be continuous. (There might be some confusion here between the antiderivative as a function and the particular value of the integral $\int_{\gamma_w} f$, which is a single complex number.) The classic example is $f(z) = 1/z$, with $a_0 = 1$. For $|w| = 1$, consider paths $\gamma^+_w$ and $\gamma^-_w$ that follow the upper and lower unit semicircle, respectively. As $w\to -1$, the integral $\int_{\gamma^+_w} f \to \pi i$, but $\int_{\gamma^-_w} f\to -\pi i$. The function $F$ we get is thus not even continuous at $w$, let alone differentiable.
In order to make $F$ differentiable, we essentially need $\gamma_w$ to vary reasonably smoothly with $w$. With path independence, we get that for free: we can just choose anything that varies smoothly with $w$, and not have to worry about trying to make individual choices for $\gamma_w$. (That's admittedly a sketch rather than a full proof, but the details should be in the notes you mentioned.)
A: Because well-definedness is not the only place within the proof that that fact is used. It is also used when the author states (page 23) that$$F(w+h)=\int_{\gamma_w*\delta_h}f(z)\,\mathrm dz.$$This is essential for what comes after that.
