Why is the structure sheaf (sheaf of rings) $\mathcal{O}$ on $\mathrm{Spec}\ A$ a sheaf?

As someone who has experienced nearly constant frustration in verifying "obvious" claims in algebraic geometry textbooks, I didn't find this one to be too bad.

Let $U_i$ be an open cover of $U$, let $s \in \mathcal O_X(U)$, and suppose $s|U_i = 0$ for all $i$. Now $s$ is a function from $U$ into the disjoint union of the rings $A_{\mathfrak p} : \mathfrak p \in U$. To say that $s$ is the zero element is to say that $s(\mathfrak p)$ is zero in $A_{\mathfrak p}$ for all $\mathfrak p$. So it is clear that $s = 0$.

Now suppose $s_i \in \mathcal O_X(U_i)$, and $s_i$ and $s_j$ agree on $U_i \cap U_j$ for all $i, j$. Then it is clear that there is a unique function $s: U \rightarrow \coprod\limits_{\mathfrak p \in U} A_{\mathfrak p}$ whose restriction to $U_i$ is $s_i$ for all $i$. Obviously, $s(\mathfrak p) \in A_{\mathfrak p}$ for all $\mathfrak p$, and the question now is whether $s$ is locally a quotient of elements from $A$.

Let $\mathfrak q \in U$. Then $\mathfrak q $ lies in some $U_i$, and since $s_i = s|U_i$ is in $\mathcal O_X(U_i)$, there exists an open neighborhood $V$ of $\mathfrak q$ and elements $a, f \in A$, with $f \not\in \mathfrak p$ for any $\mathfrak p \in V$, such that $s_i(\mathfrak p) = \frac{a}{f} \in A_{\mathfrak p}$ for all $\mathfrak p \in V$. But $s_i(\mathfrak p ) = s(\mathfrak p)$, done.