The claim is that if $Y$ is a quasi-affine variety (an open subset of an affine variety), then dim $Y = $ dim $\overline{Y}$. Here dimension is defined as the maximal length of an ascending chain of irreducible closed subsets, minus one.
Hartshorne starts with the observation that dim $Y \le $ dim $\overline{Y}$ (a chain of irreducible closed subsets of $Y$ induces a chain of irreducible closed subsets of $\overline{Y}$ by taking closures). He then states that a maximal chain of such subsets of $Y$ induces a maximal chain of $\overline{Y}$ (this claim is not explicitly proven, but I think I have worked through the details). The chain of irreducible closed subsets of $Y$ is $Z_0 \subset Z_1 \subset... \subset Z_n$, where $Z_0$ is a singleton and $n + 1$ is the maximal length of such a chain. Then $\mathfrak{m} = I(\overline{Z_0}) \subset I(\overline{Z_1}) \subset... \subset I(\overline{Z_n})$ is an ascending chain of prime ideals, where $\mathfrak{m}$ is a maximal ideal. Hartshorne concludes, by maximality of the chain of closed subsets of $\overline{Y}$, that height $\mathfrak{m} = n$.
Here is where I find the gap. Just because the chain of closed subsets of $\overline{Y}$ is maximal, in the sense that it cannot be extended to a longer chain, does not obviously mean that it is of maximal length over all such chains. If it is not of maximal length we only know height $\mathfrak{m} \ge n$. Am I correct that Hartshorne has failed to account for this, and is there a way to fill the gap?