I would like some help understanding the proof of the following version of the residue theorem.
Let $\Omega$ be an open connected subset of $\mathbb{C}$. If $f : \Omega \to \mathbb{C}$ is meromorphic with poles at $z_1,\ldots,z_n$ and $\gamma$ is a closed piecewise smooth curve in $\Omega \setminus \{z_1,\ldots,z_n\}$ such that the winding number of $\gamma$ around $z$ (denoted by $n(\gamma;z)$) is zero for all $z \not\in \Omega$, then $$\int_{\gamma}f = 2\pi i\sum_{j=1}^{n}n(\gamma;z_n)\textrm{Res}_{z=z_j}f.$$
I know that the strategy is to take a circle $\gamma_j$ around each pole $z_j$ parametrized such that $n(\gamma_j;z_j) = -(\gamma;z_j)$ and then let $\Gamma$ be the composite of the curves $\gamma,\gamma_1,\ldots,\gamma_n$. I also understand how the proof follows if we can show that $$\int_{\Gamma}f = 0.$$ The above was asserted without proof in my notes from class. My thought was to connect the circles $\gamma_j$ to the curve $\gamma$, where each connecting segment is traveled along twice in opposite directions, so as to produce a closed contour $\Gamma'$ with $\int_{\Gamma}f = \int_{\Gamma'}f$. It's easy to imagine that this is possible, but rather hard to argue formally. My professor showed us an argument similar to the one used to prove Cauchy's integral formula $$\frac{1}{2\pi i}\int_{\gamma}\frac{f(w)}{w - z}dw = n(\gamma;z)f(z),$$ in which one creates a function $$g(z) = \int_{\gamma}\frac{f(w) - f(z)}{w - z}dw$$ and extends it to an entire function which vanishes at infinity. But I can't seem to reproduce it. Any help would be much appreciated.