Question on Hartshorne II.6.1 I found the proof of Hartshorne II.Lemma 6.1 very confusing. I will break down places I'm confused by. 
First, (*) means we have a noetherian, integral, separated scheme which is regular in codimension one. 
The Lemma states: 

Let $X$ satisfy (*) and let $f \in K^{*}$ be a regular function on $X$. 
  Then $v_{Y}(f) = 0$ for all but finitely many prime divisors on $Y$. 

The statement makes sense. The proof goes:

Let $U$ be an open affine subset of $X$ on which $f$ is regular. Then $Z = X - U$ is a proper closed subset of $X$. Since $X$ is noetherian, $Z$ only contains at most finitely many prime divisors $Y$. 

Question 1: Is this because $X$ is irreducble and $U$ is open, thus dense. Then every prime divisor contained $Y$ must be contained in an proper open set of $Z$, which must intersect $U$. Hence if there where infinitely many prime divisors in $Z$, then we could have constructed an open set not intersecting $U$? 

It will be sufficient to show that there are only finitely many prime divisors $Y$ of $U$ for which $v_{Y}(f) \ne 0$. Since $f$ is regular on $U$, $v_{Y}(f) \ge 0$ in any case. 

Question 2: Why so? We only know that either $f$ has non-negative valuation or its inverse. 

And $v_{Y}(f) > 0$ iff $Y$ is contained in a proper closed subset of $U$ defined by the ideal $Af$ in $A$. Since $f \ne 0$, this is a proper closed subset of $U$, hence only contain finitely many closed irreducible subsets of codimension one in $U$. 

Question 3: I'm not following either of the sentences here. 
Many thanks! 
 A: Admittedly that proof could have used more details in my opinion.
Question 1: Either $Z$ is of codimension greater than $1$, in which case it cannot contain a prime divisor, or $Z$ is of codimension equal to $1$. In that case, prime divisors contained in $Z$ must be irreducible components of $Z$. Noetherian schemes only have finitely many irreducible components.
Question 2: The element $f$ is regular, so it lies within $\mathcal{O}_X(U)$. Looking back at the definition of the valuations, we see that for such elements the output is non-negative.
Edit: This prime divisor $Y$ will be an integral subscheme of $X$. It has a generic point $\eta$, whose stalk is $\mathcal{O}_{Y,\eta}$. By the conditions imposed on $X$, this stalk is a discrete valuation ring. This implies in particular that it has a unique maximal ideal $\mathfrak{m}_{\eta}$, that this maximal ideal is principal, say generated by some element $m$, and that every germ $g$ in $\mathcal{O}_{Y,\eta}$ can be uniquely written in the form $u m^k$ for some unit $u$, and some $k \geq 0$. 
Now, $v_Y$ is a map from the function field of $Y$ to the integers, i.e. a map $\operatorname{Frac}(\mathcal{O}_{Y,\eta}) \to \mathbb{Z}$. But how is it defined? For elements of $\mathcal{O}_{Y,\eta}$, we define it by sending $g$ to the $k$ within the expression $g = um^k$. Then, we extend it to the fraction field $\operatorname{Frac}(\mathcal{O}_{Y,\eta})$ by sending a fraction $g / h$ to $v_Y(g) - v_Y(h)$. With this in place, it is essentially by definition that a germ in $\mathcal{O}_{Y,\eta}$ gets sent to a positive value. Hence $v_Y(f)$ is non-negative if $f$ is regular. 
(Though, to be fair, I don't remember Hartshorne giving this definition, and rather he just refers to 'the valuation'.)
Question 3: I presume $A$ is the ring such that $U = \operatorname{Spec}(A)$. In that case your prime divisor $Y$ will be of the form $V(\mathfrak{p})$ for some prime $\mathfrak{p}$ of $A$. As $v_Y(f) > 0$, this means that the germ of $f$ at the generic point lies in its maximal ideal; that is, $f \in \mathfrak{p} A_{\mathfrak{p}}$, so that $f \in \mathfrak{p}$. It follows that any prime containing $\mathfrak{p}$ will in particular contain $f$, so $V(f) \supseteq V(\mathfrak{p})$.
This $V(f)$ is a proper closed subset of your scheme $X$, so by the same reasoning as in the answer to Question 1, only finitely many prime divisors are going to be within it. So there can only be finitely many such primes $\mathfrak{p}$ such that $V(\mathfrak{p})$ is within this $V(f)$, and by the previous paragraph it is only these $\mathfrak{p}$ for which $v_Y(f)$ can be greater than $0$.
