If $p$ is a closed point then $X-p$ is not an affine scheme Let $A$ be an integral, finitely-generated algebra over some field $k$, of dimension $\text{dim}(A)\geq2$ such that $A = \cap_Q A_Q$ where $Q$ runs over elements of $\text{Spec}A$ of height $1$. Let $X = \text{Spec}A$ and $p \in X$ be a closed point, i.e. a maximal ideal of $A$.

Show that the open set $X-p$ can't be an affine scheme.

I know of a solution which I don't quite understand. It goes like this:

Let $U = X-p$. If $U$ were affine, then the open immersion $U
\rightarrow X$, which isn't an isomorphism, wouldn't induce an
  isomorphism $\varphi:O_X(X) \rightarrow O_X(U)...$

Here I assume the antiequivalence of categories $\text{(opposite category of rings)}A^{opp} \rightarrow \text{Spec}A \text{ (category of affine schemes)}$
was used to go from $U \rightarrow X$ to $O_X(X)\rightarrow O_U(U) = O_X(U)$ between the associated rings, since we know that $O_{\text{Spec R}}(\text{Spec}R)=O(D(1))=R_1=R$ for any affine scheme over a ring $R$.
Since $U \rightarrow X$ does not have a reciprocal, neither does $\varphi$ which therefore isn't an isomorphism.

... But $\varphi$ is injective because $X$ is integral, and surjective
  because an element of $O_X(U)$ belongs to every $A_Q$ with $Q$ prime
  of height $1$ since $p$ is maximal of height $\geq 2$

Here I guess that $\varphi$ is just the restriction because inferring from inclusion properties one can conclude $\varphi$ follows the restriction axioms
If it really is the restriction, then it is common knowledge that since $X$ is integral, $\varphi$ is injective, as is the case of restrictions on an integral scheme.
Due to the dimension formula for finitely-generated $k$-algebras, I understand that $p$ has height $\geq2$. In particular, this means that $U$ contains all of the $Q$ prime ideals of height $1$. But I don't get how elements of $O_X(U)$ belong to $A_Q$. I can send them to $A_Q$ by considering the stalk at $Q$ but I don't see how it implies surjectivity. If the restriction is a set restriction from $A$ to some subring of $A$ then it is indeed surjective but I don't know what $\varphi$ does
Can somebody please explain about the surjectivity part? Why is $\varphi:\cap A_Q \rightarrow O_X(U)$ surjective?
 A: We want to show that $\mathcal O_X(U)\hookrightarrow A_Q,\,\forall Q$ prime of height $1$. We can show this by considering the elements of $\mathcal O_X(U)$ as follows.
The idea is to find an open cover of $U$ by standard opens of the form $D(f)$.
For every prime ideal $q\subseteq A$ not equal to $p$, choose some $f_q\in p\setminus p\cap q$ (here $p\not=p\cap q$ since $p\not\subseteq q$, so $p\setminus p\cap q\not=\emptyset$). Then $p\not\in D(f_q)$ and $q\in D(f_q)$ by definition.
So $U=\bigcup_{q\not=p}D(f_q)$, and by the sheaf property of $\mathcal O_X$, we can write $\mathcal O_X(U)$ as $$\{(a_q)_q\mid a_q\in \mathcal O_X(D(f_q))=A_{f_q},\, a_q=a_{q'}\text{ on }D(f_q)\cap D(f_{q'})\}.$$
Now we can embed $\mathcal O_X(U)$ in $A_Q$ for every $Q\in U$ by sending $(a_q)_q$ to $(a_q)_Q$, the image of $a_q$ in the stalk $A_Q$ for some $Q\in D(f_q)$. Note that if $Q\in D(f_q)\cap D(f_{q'})$, then $(a_q)_Q=(a_{q'})_Q$ by the description of $\mathcal O_X(U)$, so the map is well-defined.
And this is an injection: say $(a_q)_Q=0$ for some $Q\in U$. Then by definition of localization there is some $g\not\in Q$ such that $ga_q=0$. Since $A$ is an integral domain this implies that $a_q=0$. Now for any $q'$, we see $a_{q'}=a_q$ on $D(f_qf_{q'})$. So there is $n$ such that $(f_qf_{q'})^n(a_q-a_q')=0$. Since $a_q=0$, this shows that $a_{q'}=0,\,\forall q'\in U$.
Hence $\mathcal O_X(U)\hookrightarrow A_Q,\,\forall Q$ prime of height $1$.

Hope this helps.
A: To clear this from the unanswered queue, $\varphi$ is indeed the restriction. As you say, $\varphi$ is injective since $X$ is integral. The idea behind talking about elements of $\mathcal{O}_X(U)$ belonging to $A_Q$ is that one may embed both rings in $K(X)$, their common field of fractions, and compare there. As $\varphi$ is injective, you get that inside $K(X)$, we have $\mathcal{O}_X(X)\subset \mathcal{O}_X(U)$. Next, $\mathcal{O}_X(U)\subset A_Q$ for every prime $Q$ of height one, as $U$ contains all such $Q$. But this means that $\mathcal{O}_X(U) \subset \bigcap A_Q$, and $\bigcap A_Q=\mathcal{O}_X(X)$ by assumption. So $\mathcal{O}_X(X)\subset \mathcal{O}_X(U)\subset\mathcal{O}_X(X)$, and thus both inclusions must be equalities.
