Let $\omega$ be an exact $1$-form on a path-connected manifold $M$. For a fixed $x \in M$ we can define for all $y \in M$. $$ g(y) := \int_\gamma \gamma^*(\omega), $$ where $\gamma$ is a path from $x$ to $y$. Because $\omega$ is exact, it is independent of $\gamma$. What I want to show is that $dg = \omega$. My thought is that $$ d\left( \int_\gamma \gamma^*(\omega) \right) = \int d(\omega(\gamma)), $$ because $d$ commutes with integration, and $\gamma^*(\omega)$ is defined to be $\omega(\gamma(t))$. Then $$ d(\omega(\gamma)) = d\omega(\gamma) \cdot d\gamma $$ by chain rule. By change of variable, we get $$ \int d \omega = \omega. $$ But, someone pointed out that $d\omega = 0$ by exactness. My thought is that this is only true when integrating over closed paths. What's going on? Thanks.
Edit: Another thought is that $d(\omega)$ and $d\omega$ are two different things. So, that $d(\omega) = 0$, but $d\omega$ is a element of the cotangent bundle. Thus, $d\omega$ is not $0$.