Wanting to check that finite-type morphisms of integral schemes restrict to finite morphisms So I am only just starting to become familiar with schemes, and having had some previous work checked, I seem to have a habit of overlooking subtitles which I would really like to have cleared up early. I realize it's a big post, but I would really appreciate if anyone could have a look through and see if what I have done seems valid (or if there are any suggestions of more elegant solutions).
So the question is from Hartshorne, II (exercise 3.7). I am given a dominant, finite-type, generically finite morphism $f: X \longrightarrow Y$  of integral schemes. I am required to show that there is an open dense subset $U \subseteq Y$ such that the induced morphism $f^{-1}(U) \longrightarrow U$ is finite.
The following is my attempt at a solution.
Let $f: X \longrightarrow Y$ be a finite-type morphism of integral schemes. Let $\eta \in Y$ be the generic point of $Y$ and let $\varepsilon \in X$ be the generic point of $X$ (each scheme has a unique generic point since they are irreducible). Since each scheme is the topological closure of their generic point, it must be the case that any open set must contain the generic point, and hence must be dense. Now choose any affine open set $\text{Spec } B$ of $Y$, and since $f: X \longrightarrow Y$ is finite type, we have that 
$$
f^{-1} (\text{Spec }B) = \bigcup_{i = 1}^{N} \text{Spec } A_{i}
$$
where each $A_{i}$ is a finitely generated $B$-algebra, via morphisms
$$
\phi_{i}: B \longrightarrow A_{i}.
$$
Since $X$ is irreducible, any of the $\text{Spec } A_{i}$ are dense and must contain the generic point $\varepsilon$. Now choose a particular one of the $\text{Spec }A_{i}$ which contains $f(\eta)$, call it $\text{Spec } A$. Now we have that the morphism
$$
g:=f|_{\text{Spec }}: \text{Spec } A \longrightarrow \text{Spec }B
$$
is itself dominant, since its image includes the generic point of $\text{Spec } B$. Now we claim that the corresponding morphism of algebras
$$
\phi: B \longrightarrow A
$$
is injective. Suppose we have $h \in B$ with $\phi(h)= 0$. Then we have
$$
g^{-1}(D(h)) = D(\phi(h)) = D(0) = \emptyset.
$$
But since $g$ is dominant, this must mean that $D(h)$ is empty, which can only happen if $h$ is nilponent. But since $B$ is an integral domain, we have that $h = 0$. By definition of $A$ being a finitely generated $B$-algebra, we have an exact sequence
$$
B[x_{1}, x_{2}, \ldots x_{m}] \longrightarrow A \longrightarrow 0
$$
Now let $S$ be the multiplicative set of $B$ of all non-zero elements. By right exactness of the tensor product (treating $A$ as a $B$-module), we have
$$
S^{-1}B [x_{1}, x_{2}, \ldots , x_{m}] \longrightarrow A \otimes_{B} S^{-1}B \longrightarrow 0
$$
The ring $S^{-1}B$ is the field of fractions of $B$ by definition. I claim also that $A \otimes_{B} S^{-1}B$ is the field of fractions of $A$. Indeed any map $A \longrightarrow R$ to some ring $R$ which sends all non-zero elements of $A$ to invertible elements in $R$ can be precomposed with $\phi$, and by the injectivity of $\phi$, this becomes a map $B \longrightarrow R$ that sends every non-zero element of $B$ to an invertible element. Then by the universal property of the localization of $B$, as well as the universal property for the tensor product, we can show that $A \otimes_{B} S^{-1}B$ satisfies the appropriate universal property. We denote the function fields of $X$ and $Y$ by $\kappa(\varepsilon)$ and $\kappa(\eta)$ respectively. This gives us an exact sequence
$$
\kappa(\eta) [x_{1}, x_{2}, \ldots x_{m}] \longrightarrow \kappa(\varepsilon) \longrightarrow 0.
$$
And so $\kappa(\varepsilon)$ is finitely generated as an algebra over $\kappa(\eta)$. But then by Zariski's lemma, this is a finite field extension. 
Now observe that $\text{Spec } (\kappa(\varepsilon))$ and $\text{Spec } (\kappa(\eta))$ are open sets of $X$ and $Y$ respectively via immerions
\begin{align*}
\text{Spec }(\kappa(\varepsilon)) \hookrightarrow \text{Spec } A \hookrightarrow X \\
\text{Spec }(\kappa(\eta)) \hookrightarrow \text{Spec } B \hookrightarrow Y \\
\end{align*}
and since we already have that $\kappa(\varepsilon)$ is a finite $\kappa(\eta)$-module (vector space), it remains only to show that $f^{-1}(\text{Spec }(\kappa(\eta))) = \text{Spec }(\kappa(\varepsilon))$, or equivalently, that $f^{-1}(\eta) = \{ \varepsilon \}$. Now suppose $p \in X$ is any point such that $f(p) = \eta$. Then we have morphisms
$$
\mathcal{O}_{Y, \eta} \longrightarrow \mathcal{O}_{X, p} \longrightarrow \mathcal{O}_{X, \varepsilon}
$$
where the first map arises from the morphism of schemes, and the second arises from universal property of the colimit since $p$ is a specialization of $\varepsilon$. But since $\mathcal{O}_{Y, \eta}$ and $\mathcal{O}_{X, \varepsilon}$ are themselves fields, we deduce that $\mathcal{O}_{X, p}$ is a field. So then we find that $p$ is generic, and since the generic point is unique, we have that $p = \varepsilon$.
 A: This answer is probably going to be incomplete, but let me point out a few things which go wrong in your proof:


*

*One of your assumptions is that the morphism is generically finite. Not only do you never use this, you actually reprove it. Now while this is a bit of a meta argument, you should suspect that there is something wrong. Let me point out that $Spec(\mathbb{Q}[X]) \to Spec(\mathbb{Q})$ is a counterexample without this hypothesis (why?).

*The proof that $A \otimes_B S^{-1}B$ is the field fractions of $A$ is wrong (you can see in the above example that the claim is already incorrect). The fraction field $A \to F(A)$ has the universal property of being a field and giving a factorization $A \to F(A) \to R$ for each morphism $A \to R$ sending non-zero elements to units. If you drop the requirement of being a field, $A$ itself or any localization of it satisfy the new property (in the example above, this is again $A = \mathbb{Q}[X]$).

*The reasoning why $\mathcal{O}_{X,p}$ has to be a field seems incomplete. Sitting between two fields does not make your ring a field. (In the example above, this would be $\mathbb{Q} \to \mathbb{Q}[X]_{(X)} \to \mathbb{Q}$)

*Finally, as Marc Paul already pointed out, the generic points are usually not open in you scheme. That's actually what this exercise is about: You are given finiteness at the generic points, and you are supposed to 'spread it out' to actual open subsets.
