Hartshorne theorem II.8.19 There is a step in this proof I don't understand and maybe someone who does can help clarify it to me. The theorem is the following:

Let $X$ and $X'$ be birationally equivalent non-singular projective varieties over a field $k$. Then $p_g(X)=p_g(X')$

The proof has two steps, first show there is an open set $V\subset X$ and an injective map $\Gamma(X',\omega_{X'})\to \Gamma(V,\omega_V)$ and then show that $\Gamma(X,\omega_X)\to \Gamma(V,\omega_V)$ is bijective. As our open set $V$ we pick the largest open set on which some given rational equivalence $X\to X'$ is defined. Then to prove the second part Hartshorne begins by showing that the complement of $V$ has codimension $\geq 2$. This is what I understand from his argument. If $P\in X$ has codimension $1$ we get a commutative diagram as below
$$\text{Spec}(\mathcal{O}_{\xi,X})\longrightarrow X'\\
\downarrow \ \ \quad\quad\quad\quad \downarrow\\\text{Spec}(\mathcal{O}_{P,X})\longrightarrow \text{Spec}(k)$$
where $\xi$ is the generic point of $X$. Then since $X'\to \text{Spec}(k)$ is proper and $\mathcal{O}_{P,X}$ is a DVR we get a unique map $\text{Spec}(\mathcal{O}_{P,X})\to X'$. But I don't understand what comes next. Hartshorne says this unique map is compatible with the birational map and that it extends to some neighborhood of $P$. I don't know why either of these claims are true. Any help would be appreciated!
 A: If we have an extension of our map $\operatorname{Spec}\mathcal{O}_{X,P}\to X'$ as claimed, then it induces the same map on function fields by construction: the map on function fields is given by the induced map at the generic point. But two dominant rational maps inducing the same map on function fields are equivalent - this is covered in section I.4, for instance.
Now let's tackle the extension to a neighborhood of $P$. Let $U=\operatorname{Spec} A\subset X$ be an affine open neighborhood of $P$ and let $U'=\operatorname{Spec} A'\subset X$ be an affine open neighborhood of $P'$, the image of $P$. We have a morphism $A'_{P'}\to A_P$ from the map $\operatorname{Spec} \mathcal{O}_{X,P}\to\operatorname{Spec} \mathcal{O}_{X',P'}$, and since $A'$ is finitely generated over $k$ because $X'$ is of finite type, we can look at the composite map $A'\to A'_{P'}\to A_P$ and deduce a compatible map $A'\to A_f$ where $f$ is the product of all the denominators of the images of the generating set for $A'$. This gives an extension of $\operatorname{Spec} \mathcal{O}_{X,P}\to X$ to  $\operatorname{Spec} A_f\to X'$, where $\operatorname{Spec} A_f$ is an open affine neighborhood of $P$ in $X$.
