Hartshorne Exercise II 3.22 (a) - Dimensions of the Fibres of a morphism I'm currently stuck at Exercise II 3.22 (a) in Hartshorne's Algebraic geometry, which states

Let $f: X \to Y$ be a dominant morphism of integral schemes of finite type over a field $k$, and let $Y' \subset Y$ be an irreducible closed subset whose generic point $\eta'$ is contained in $f(X)$. Let $Z \subset X$ be an irreducible component of $f^{-1}(Y')$, whose generic point $\zeta$ maps to $\eta'$. Then $$\operatorname{codim}(Z, X) \leq \operatorname{codim}(Y', Y).$$

If $\operatorname{codim}(Z, X) = r$, and $Z = Z_0 \subsetneq Z_1 \subsetneq \dotsb \subsetneq Z_r = X$ is a maximal chain of irreducible closed subsets, I would like to show that the generic points $\zeta_i$ of the $Z_i$'s are mapped to distinct points in $X$. I think this would imply that the closures $Y_i = \overline{\{f(\zeta_i)\}}$ form a chain of irreducible closed subsets containing $Y'$.
But I only know that $f(\zeta_1) \neq \eta'$, because otherwise $Z_1$ would be contained in $f^{-1}(Y')$, which contradicts the assumption that $Z$ is an irreducible component, and also $f(\zeta_r) = \eta$, there generic point of $Y$.
Any help would be appreciated :)
 A: $\DeclareMathOperator{\Spec}{Spec}
\DeclareMathOperator{\codim}{codim}
\DeclareMathOperator{\ht}{ht}$By Exercise II 3.20, the codimension of $Z \subset X$ equals $\dim \mathcal{O}_{X, \zeta}$, and similarly for $Y'
$. Hence the question is local, and we can assume that everything is affine, i.e. $X = \Spec B$, $Y = \Spec A$, $Z = V(P)$ and $Y' = V(\mathfrak{p})$, and $f: X \to Y$ is given by a ring homomorphism $\varphi: A \to B$.
Now $\codim(Z, X) = \dim \mathcal{O}_{X, \zeta} = \dim B_P = \ht P$, and similarly $\codim(Y', Y) = \ht \mathfrak{p}$.
Then use the following theorem from Matsumura's Commutative ring theory:

Theorem 15.1. Let $\varphi: A \to B$ be a homomorphism of Noetherian rings, and $P$ a prime ideal in $B$; then setting $\mathfrak{p} = P \cap A$, we have $$\operatorname{ht} P \leq \operatorname{ht} \mathfrak{p} + \dim B_P / \mathfrak{p} B_P.$$

So it remains to show $\dim B_P / \mathfrak{p}B_P = 0$. The assumption that $Z$ is an irreducible component of $f^{-1}(Y')$ means that $P$ is a minimal prime ideal of $V(\mathfrak{p}B) \subset \Spec B$, hence $V(\mathfrak{p}B_P) = \{P\} \subset \Spec B_P$, and so $\dim B_P / \mathfrak{p}B_P = 0$.
I'm only a bit confused because I didn't use that $f$ is dominant (i.e. $\varphi$ is injective). But maybe this becomes relevant in the other parts of the exercise.
