I am trying to understand the last part of theorem 3.1. of Hartshorne's Algebraic Geometry, which says:
A scheme is integral iff is both reduced and irreducible.
In the $(\Longleftarrow)$ part:
Suppose that $X$ is reduced and irreducible. Let $U\subset X$ be an open subet, and suppos that there are elements $f,g\in \mathcal{O}(U)$ with $fg=0$. Let $Y=\{x\in U|f_x\in m_x\}$, and let $Z=\{x\in U|g_x\in m_x\}$. Then $Y$ and $Z$ are closed subsets wituh union $U$. But $X$ is irreducible, so $U$ is irreducible, so one of $Y$ or $Z$ is equal to $U$, say $Y=U$.
Then I get stuck on this part:
But then the restriction of $f$ to any open affine subset of $U$ will be nilpotent, hence zero, so $f$ is zero.
What I am trying is:
Let $V\subset U$ an open affine subset of $U$, $x\in V$, then there is a ring $R$ such that $$(V,\mathcal{O}_U|_V)\cong (\operatorname{Spec} R,\mathcal{O}_{\operatorname{Spec} R}).$$
Let $\psi:\operatorname{Spec} R\to V$, $f^{\#}(V):\mathcal{O}_U|_V(V)\to \mathcal{O}_{\operatorname{Spec} R}(\operatorname{Spec} R)\cong R$ be this isomorphism.
Also let $\overline{f}=f_V\in \mathcal{O}_U|_V(V)$, so $\overline{f}_x\in \mathcal{m}_x$ . In exercise 2.16. it is defined $$X_f:=\{x\in X|f_x\not\in\mathcal{m}_x\}.$$
As $\overline{f}_x\in \mathcal{m}_x$, $X_{\overline{f}}=X_f$. Also, as $Y=\{x\in U|f_x\in m_x\}=U\setminus X_f$ and $Y=U$, $X_f=\emptyset$
Let $r:=\psi^{\#}(\overline{f})$, so $\mathcal{O}_{\operatorname{Spec} R}(D(r))\cong R_r$.
I want to show that $X_{\overline{f}}=\emptyset$ implies that $D(r)=\emptyset$.
If so then $$R_r\cong \mathcal{O}_{\operatorname{Spec} R}(D(r))=0$$ and this implies that $r$ is nilpotent, and consequently $\overline{f}$ and finally $f$. As $f\in \mathcal {O}_X(U)$ and $\mathcal {O}_X(U)$ is reduced, we conclude that $f=0$.
Am I doing correctly? Thank you,