Let $M \subset \mathbb{R}^3$ be a $2$-dimensional smooth and connected manifold. I need to prove that the following two claims are equal:
For every smooth path $\gamma :[0,1] \to M$ it satisfies $$\int_\gamma xdx + ydy +zdz = 0$$
$M$ is contained in a sphere around the origin.
I started by writing $\omega = xdx+ ydy+zdz$. Then the function $f(x,y,z) = \frac{x^2+y^2+z^2}{2} +c$ satisfies $\omega = df$, which means that $\omega$ is exact.
Thus, I can write $\int_\gamma \omega = f(\gamma(1)) - f(\gamma(0))$
From here it is easy to see that $2 \rightarrow 1$ because if we assume $2$, then every point on $M$ is on the same sphere, which means that for every $(x,y,z) \in M$: $x^2+y^2+z^2 = r^2$ for the same $r$ and then $f(\gamma(1)) - f(\gamma(0)) = 0$
However, I don't see how to prove $1 \rightarrow 2$. I think it has to do with the fact that $M$ is connected, since I didn't use it yet, but I don't know how.
Help would be appreciated.
To prove $1 \implies 2$, you use the equation $0 = \int_\gamma \omega = f(\gamma(1)) - f(\gamma(0))$ to prove that $f$ is locally constant on $M$, because any two points in a coordinate neighborhood of $M$ are endpoints of some smooth path.
Since $M$ is connected, it follows that $f$ is globally constant.
Hence $x^2+y^2+z^2$ is constant on $M$, so $M$ is contained in a sphere around the origin.