Application Hilbert's Nullstellensatz for $k$-algebra of finite type Let $A$ be a $k$-algebra of finite type and an integral domain. Furthermore set $X=\operatorname{Spec}(A)$ the affine scheme.
Let $U \subset X$ an arbitrary open subscheme of $X$. The main goal is to show that $\dim U = \dim X$ holds and i know that there are many ways to do it but this question refers concretely to following argument presented in Bosch's "Algebraic Geometry and Commutative Algebra" (p. 376):
There are two steps which aren't clear to me there:


*

*In first step he says that the set of closed points of $U$ is dense in $X$. His argument was an application of Hilbert's Nullstellensatz. Can anybody explain to me how this step works. I don't see how the HN is incorporated here.

*After having shown 1. according to the proof the statement $\dim U = \dim X$ should follow instantly. Why?
Remark: The problem here isn't just to see why $\dim U = \dim X$ holds but to understand concretely to two steps used in the argument above.
 A: I can at least answer question one. The version of Hilbert's Nullstellensatz being used here is often called Zariski's lemma, and says: if $B$ is a field which is finitely generated as a $k$-algebra, then $B$ is a finite field extension of $k$ (i.e., $B$ is finite as a $k$-module.) With this in mind, let's proceed. 
Let $A$ be a finitely generated $k$-algebra. First, we will show that the closed points of $X = \mathrm{Spec}(A)$ are dense in $A$. To do so, it suffices to show that for any $f \in A$ such that the distinguished open $D(f)$ is nonempty, there is a closed point of $A$ in $D(f)$. Let $f \in A$ be such that $D(f)$ is nonempty; we recall that $D(f)$ is the image of the open embedding of schemes $\varphi \colon \mathrm{Spec}(A_{f}) \to \mathrm{Spec}(A)$ induced by the canonical localization morphism $\alpha \colon A \to A_{f}$. 
Note that $A_{f}$ is not the zero ring, since $D(f)$ is nonempty. Hence, $A_{f}$ has a maximal ideal $M$, i.e. there is a point $M \in \mathrm{Spec}(A_{f})$ which is closed. If we can show that $\varphi(M)$ is a closed point of $A$, then we're done. This will be our strategy. (As an aside, it's worth noting that this step is where our argument breaks down if $A$ is not finitely generated as a $k$-algebra; consider $A = k[X]_{\langle X \rangle}, f = X$, for example.)  
Indeed, $A_{f}$ is also a finitely generated $k$-algebra, and therefore so is $A_{f}/M$. Since $A_{f}/M$ is a field, $A_{f}/M$ is a finite field extension of $k$ by the Hilbert Nullstellensatz. Let $P = \varphi(M) = \alpha^{-1}(M) \in \mathrm{Spec}(A)$. Then $P$ is precisely the kernel of the composition $A \to A_{f} \to A_{f}/M$, and hence we obtain an injection of $k$-algebras $A/P \hookrightarrow A_{f}/M$. But $A_{f}/M$ is a finite-dimensional $k$-vector space, and therefore $A/P$ is an integral domain which is a finite-dimensional $k$-vector space. By a well known lemma, $A/P$ is thus a field, and $P$ is a closed point of $\mathrm{Spec}(A)$ in $D(f)$, as desired.
Now, let $U \subset X$ be a (nonempty) open subscheme. Note that any closed point of $X$ contained in $U$ is a closed point of $U$ in the subspace topology, so it suffices to show that for any nonempty open subset $V \subset X$, $V \cap U$ contains a closed point of $X$. 
First, note that $X$ is an irreducible topological space, since $A$ is a domain. This is because $(0)$ is a prime ideal of $A$, and the closure of $\{(0)\}$ in $X$ is $V((0)) = \mathrm{Spec}(A)$. It is a well known fact from topology that any two nonempty open subsets of an irreducible topological space have nonempty intersection. Now, suppose $V$ is a nonempty open subset of $X$. Since $U$ is also nonempty, the intersection $U \cap V$ is a nonempty open subset of $X$. Since the closed points of $X$ are dense in $X$, it follows that $U \cap V$ must contain a closed point of $X$, as desired. 
As a final observation, note that the hypothesis that $A$ is a domain is crucial here. It is always true that the closed points of $X$ are dense in $X$ when $A$ is a finitely generated $k$-algebra, whether or not $A$ is a domain. However, it is not true that the closed points of any nonempty open $U \subset X$ are dense in $X$ without the assumption that $A$ is a domain. A counterexample is given by choosing any $A$ such that $\mathrm{Spec}(A)$ contains two nonempty open subsets which do not intersect, and picking one of these to be $U$. For a concrete counterexample, recall that the spectrum of any Artinian ring is finite and discrete, and so every point is simultaneously open and closed. Taking $A$ to be an Artinian ring which is finitely generated as a $k$-algebra but not a domain and $U$ to be a point $\mathrm{Spec}(A)$ then gives a counterexample; for example, to be explicit, one could take $A = k[X]/\langle X^2 \rangle \times k[Y]/\langle Y^{3} \rangle$. Of course, any Artinian domain is a field, and so has spectrum consisting of a point, so this is not a problem under our hypotheses.  
