Proving that an integral is a holomorphic function Let $U\in \mathbb C$. Let $f:U\to\mathbb C$ be analytic on $U$ and continuous on the boundary of $U$. I want to prove that, for each $a\in U$, and sufficiently small $r>0$, 
$$
g(w)=\frac{1}{2\pi i}\int_{|z-a|=r}\frac{zf'(z)}{f(z)-w}dz
$$
defines a holomorphic function.
My attempt: Assume for a moment that $f$ is injective (not actually valid). Using the substitution $x=f(z)$, we get
$$
g(w)=\frac{1}{2\pi i}\int_{|f^{-1}(x)-a|=r}\frac{f^{-1}(x)}{x-w}dx=f^{-1}(w)
$$
by Cauchy integration formula, since $f^{-1}$ is analytic (because $f'(z)\neq0$).
Is this valid? I feel something missing. For example, I have not addressed the condition "sufficiently small r". What's wrong?

EDITED: 
More generally, let $\mu$ be a complex (finite) measure on a measurable space $X$, $\varphi$ a measurable function on $X$, and $V$ an open subset of $\mathbb C$ that does not intersect $\varphi(X)$.  Then
$$ g(z) = \int_X \frac{d\mu(x)}{\varphi(x) - z}$$
is analytic in $V$.  You can prove this using Morera's theorem.  
In the OP's case, $V = \mathbb C \backslash f(\Gamma_r)$ where $\Gamma_r$ is the circle $|z-a| = r$.  Note that for any $w \ne f(a)$, you can take $r$ small enough that $w \in V$.
