I'm reading Hartshorne, and was wondering if this was true:
Let $A$ be a ring and let $U$ be an open subset of $Spec(A)$. Let $S$ be the set of elements of $A$ not in any prime of $U$. Then $S$ is multiplicatively closed and $\mathcal{O}_A|_U \cong Spec(A[S^{-1}])$ as schemes.
It seems like you would certainly want open subsets of affine schemes to be affine, but I can't seem to find a proof in Hartshorne. Perhaps it's too "obvious" to bother proving, but here is a supposed proof:
$S$ is obviously multiplicatively closed. The map $A \rightarrow A[S^{-1}]$ induces an inclusion-preserving bijection between primes not meeting $S$ and primes of $A[S^{-1}]$. I claim that the primes in $U$ are precisely those that do not meet $S$: if $U^c = V(\mathfrak{a})$, then we show that some element of $S$ lies in $\mathfrak{a}$. If not, then each element of $\mathfrak{a}$ is not in $S$, and so $\mathfrak{a} \subset \bigcup \big\{\mathfrak{p} : \mathfrak{p} \in U\big\}.$ A result of commutative algebra (Atiyah-MacDonald Prop 1.11) then has $\mathfrak{a} \subseteq \mathfrak{p}$ for some $\mathfrak{p}$, a contradiction. Hence any prime not in $U$ contains $\mathfrak{a}$ and so meets $S$. The primes that are in $U$ do not meet $S$ by definition.
This gives a homeomorphism $\phi:U \rightarrow Spec(A[S^{-1}])$ on the level of spaces. We now build an isomorphism of schemes. Let $W$ be an open set of $A[S^{-1}]$. The correspondence of ideals gives an open set in $U$, which we will denote $V$. Suppose $F:W \rightarrow \bigsqcup_{\mathfrak{p} \in W} A[S^{-1}]_\mathfrak{p}$ is locally a fraction. Pick $\mathfrak{p} \in W$. Then let $f = \frac{a}{s} \in A[S^{-1}]$ satisfy $\mathfrak{p} \in D(f) \subseteq W$, and choose $b \in A$ such that $F(\mathfrak{q}) = \frac{b}{f} \in A[S^{-1}]_\mathfrak{q}$ for each $\mathfrak{q} \in D(f)$. Now, if $\mathfrak{p} \in D(f)$, then $\mathfrak{p}\cap A$ does not contain $a$, and conversely. So $D(f)$ is sent to the open set $D(a)$ in $A$. So if we define $G$ on $V$ by $G(\mathfrak{p}\cap A) = F(\mathfrak{p}) \in A[S^{-1}]_\mathfrak{p} \cong A_{\mathfrak{p}\cap A}$, then on $D(a)$, we have $G(\mathfrak{p}\cap A) = F(\mathfrak{p}) = \frac{b}{f} = \frac{sb}{a} \in A_{\mathfrak{p} \cap A}$. So $G$ is locally a fraction, and so this defines $\Gamma(A[S^{-1}], W) \rightarrow \Gamma(A,V)$ and so produces a morphism of schemes. On stalks, this morphism is an isomorphism, and so the morphism itself is an isomorphism of schemes.
Does this proof look correct? I'm always afraid I've missed something subtle with these things.
EDIT: I have figured out where the proof is wrong. The cited Atiyah-Macdonald proposition only holds for finite unions of prime ideals.