I was trying to solve the following exercise. I wanted to check if my solution was correct/rigorous enough, and ask a question at the end. (The general direction is given in here: holomorphic map between compact Riemann surfaces, and I seem to have expanded out the steps in a detailed way)
Let $h\colon X \rightarrow Y$ be a morphism of Riemann surfaces. Assume that $X$ is connected and $h$ is not constant. Show that the image of $h$ is open in $Y .$ Deduce that $h$ is surjective if we moreover assume that $X$ is non-empty and compact, and $Y$ is connected. This implies that a morphism from a connected compact Riemann surface to a connected non-compact Riemann surface is always constant. In particular, every holomorphic function on a connected compact Riemann surface is constant.
Open mapping theorem: If $U$ is a connected open subset of $\mathbb{C}$, then the image of every non-constant holomorphic function $f: U \rightarrow \mathbb{C}$ is open.
Proof: Let $h\colon X \rightarrow Y$ be such a morphism. Let $O \subset X$ be an open subset of $X$, and we will show $h(O)$ is open. For any $x \in O$, let $(U,\phi)$ be a chart of $O$ containing $x$, and $(V,\psi)$ a chart of $Y$ containing $h(x)$. Then consider the holomorphic map $\psi \circ h \circ \phi^{-1}$ defined on the open set $\phi(U \cap h^{-1}(V))\ni\phi(x)$. Draw an open neighbourhood around $\phi(x)$, and apply $\psi \circ h \circ \phi^{-1}$ to it. The result is an open in $\mathbb{C}$ around $\psi \circ h(x)$, using the open mapping theorem. Composing from the left with $\psi^{-1}$, we obtain an open neighbourhood around $h(x)$. Since this holds for any point $x \in O$, $h(O)$ is open in $Y$.
Now assume that $X$ is connected, non-empty, compact, and $Y$ connected. Let the notation be as above. Then $h(X)$ is compact, non-empty, and connected. As $h$ is an open map, $h(X)$ is open in $Y$. As $h(X)$ is compact, it is closed in Hausdorff space $Y$. As $Y$ is connected, we conclude $h(X) = Y$. Now, if $Y$ is non-compact, a continuous map cannot map a compact space to a non-compact space, so $h$ must be a constant (otherwise we proved it is surjective).
Is my solution correct? Also, I do not understand why this implies that every holomorphic function on a connected compact Riemann surface is constant.