Hartshorne generically finite morphisms (II, 3.7) I have a question concerning one of the exercises of Hartshorne, Ch. II. Namely: Exercise 3.7 about gerneically finite morphisms.

A morphism $f: X \rightarrow Y$ with Y irreducible and $\eta$ generic point of Y, is called generically finite, if $f^{-1}(\eta)$ is a finite set. Now let $f: X \rightarrow Y$ be a dominant, generically finite morphism of finite type of integral schemes. Show that there is an open dense subset $U \subseteq Y$ sth. $f^{-1}(U) \rightarrow U$ is finite.

As a hint, one should prove first that the function field of $X$ is a finite field extension of the function field of $Y$.
I have started with the affine case: $X = \operatorname{Spec}\ A$, $Y = \operatorname{Spec}\ B$ with function fields $K$ resp. $L$. The assertion that $K$ now is a finite field extension of $L$ follows from Noether's Normalization theorem and Zariski's Lemma. 
But how can I proceed from there? I would be grateful for an idea to help me go on. Thank you!
 A: Here's a diagram of the algebraic setup. All the arrows are inclusions.
$$
\require{AMScd}
\begin{CD}
A @>>> A \otimes_B L @>>> K\\
@AAA @AAA\\
B @>>>L
\end{CD}
$$
Since $K$ is finite over $L$ you know that algebra generators for $A$ over $B$ satisfy monic polynomials with coefficients in $L$. If you localize $B$ at a well-chosen element $f$ you can upgrade this statement!
A: I want to post a message to say, after applying Hoot's answer, you're still 'not done yet' (this problem is quite technical).
Let's recall the situation. You can reduce to $f:X\rightarrow Y=\operatorname{Spec} B$ dominant morphism of integral schemes of finite type (we no longer need the generically finite assumption) inducing a finite extension $K(Y)\rightarrow K(X)$. This means that $X$ is covered by $U_i=\operatorname{Spec} A_i$ open such that $B\rightarrow A_i$ is finitely generated, and $A_i$ is generated by elements algebraic over $B$ as Hoot said. Note that in fact $B\hookrightarrow A_i$ is mono ($\forall i$) since $U_i$ is dense in $X$ since $X$ irred., and $f$ is dominant, so $U_i$ is dense in $Y$. Let $x_{ij}$ generate $A_i$ over $B$. Then $x_{ij}$ satisfies an equation of algebraic dependence over $B$ with leading coefficient $b_{ij}$. Put $U=\{b_{ij}\}_{i,j}$; then $W:=\operatorname{Spec} B[U^{-1}]$ is an open affine subset of $Y$ and again since $U_i\rightarrow Y$ is dense, $f^{-1}(W)\cap U_i\ne\emptyset\forall i$. Moreover, now $B[U^{-1}]\hookrightarrow A_i[U^{-1}]$ has $A_i[U^{-1}]$ finitely generated by integral elements; hence is finite over $B[U^{-1}]$.
We have reduced to $f : X\rightarrow Y=\operatorname{Spec} B$ with $U_i=\operatorname{Spec} A_i$ covering $X$ and $B\hookrightarrow A_i$ finite. But we need to find a nonempty open subset $V\subset Y$ such that $f:f^{-1}(V)\rightarrow V$ is finite (in particular, affine). Put $W:=\bigcap U_i$ (nonempty open since $X$ irred.). Let $\mathfrak a_i\subset A_i$ be such that $U_i\supset V(\mathfrak a_i)=U_i-W$. $B\subset A_i$ are integral domains, and $K(A_i)$ is algebraic over $K(B)$. It is then a fact that every nonzero ideal of $A_i$ intersects $B$ nontrivially. $\mathfrak a_i$ is nonzero since $W\ne\emptyset$. Hence $\exists f_i\in B\subset A_i$ such that $D(f_i)\subset W\subset U_i$. Put $U:=\{f_i\}_i$. Then $V:=\operatorname{Spec} B[U^{-1}]$ is nonempty affine open in $Y$ and so $\emptyset\ne f^{-1}(V)\subset W$. Note that $f^{-1}(V)$ coincides with $\bigcap_i X_{f_i}$, where $f_i$ is the image of $f_i$ in $\Gamma(X,\mathscr O_X)$ ($B$ injects into global sxns since $f$ dominant). Moreover $f^{-1}(V)\subset W$ hence coincides with $\bigcap_i X_{f_i}\cap U_j=\bigcap_i D(f_i)\cap U_j\forall j=\operatorname{Spec} A_j[U^{-1}]$, where as always we identify $B$ with its image as appropriate. Hence $f:f^{-1}(V)\rightarrow V$ is our desired finite morphism.
One last thing: here is a different (probably functionally equivalent) way to prove that $K(X)$ is a finite extension of $K(Y)$. Reduce to $f:\operatorname{Spec} A=X\rightarrow Y=\operatorname{Spec} B$ dominant generically finite morphism of integral affine schemes of finite type. Identifying $B$ with its monomorphic image we have $B\subset A$ domains with only finitely many primes of $A$ lying over $(0)\in\operatorname{Spec} B$. Replacing $B$ by $K(B)$ we have $A$ finitely generated over a field hence Noetherian and Jacobson (by the Nullstellensatz). A Noetherian ring $A$ is Jacobson iff $\forall\mathfrak p\in\operatorname{Spec} A$ of dimension one, $R/\mathfrak p$ has infinitely many ideals. $A$ has only finitely many ideals after replacing $B$ by $K(B)$, so all primes of $A$ must be maximal. Thus $A$ is Artinian (and Noetherian) hence finite over $K(B)$. Therefore $K(A)=K(X)$ is a finite extension of $K(B)=K(Y)$.
