Is a morphism of smooth connected curves over an algebraically closed field either finite flat or constant?

Let $X$ and $Y$ be two proper smooth connected curves over $S = \text{Spec}\ k$, where $k$ is an algebraically closed field.

Let $f$ be an $S$-morphism $X \to Y$, then in [KM, p74] it is stated that $f$ is either finite flat or constant. I do not see why/how. Also a search did not give me results on where to find a proof.

When assuming that $X$ and $Y$ are elliptic curves, I do see:

• $X$ and $Y$ are projective over $S$
• Therefore $f$ is projective
• And the statement (intuitively) makes sense to me over $\mathbb{C}$.

But I do not see why this is true in the more general setting.

[KM] : N. M. Katz — B. Mazur, Aritmetic Moduli of Elliptic Curves. Annals of Mathematics Studies, Princeton University Press, 1985

-

But it is not difficult (fill in the details!): If $f$ is not constant, it is surjective. Then, since $Y$ is a Dedekind scheme, $f$ is flat. Since it is quasi-finite and proper, it is finite.