Fibre products of closed subschemes

Let $U = Spec(A)$ and $V = Spec(B)$ be affine schemes. Let $X$ be a separated scheme. Suppose that there exist morphisms $U \to X$ and $V \to X$. Then is the natural map $$A \otimes_{\Gamma(X, \mathcal O_X)} B \to \Gamma(U \times_X V, O_{U \times_X V})$$ surjective?

• Actually this is a well-known characterization of separated schemes (plus that $U \times_X V$ is affine), you can find it in the books by EGA, Görtz-Wedhorn and Bosch. – Martin Brandenburg Jun 15 '13 at 6:55

Let $Y=\operatorname{Spec}(\Gamma(X,\mathcal{O}_X)).$ We have a natural morphism $X\rightarrow Y$ corresponding to the identity map on $\Gamma(X,\mathcal{O}_X)$. We thus have morphisms from $U$ and $V$ to $Y$ as well by composition.
Now, consider $U\times_XV$ and $U\times_YV$. For general schemes $U,V,X,Y$ with maps $U,V\rightarrow X$ and $X\rightarrow Y,$ there is a map $U\times_X V\rightarrow U\times_Y V$ and this map is a base change of the map $X\rightarrow X\times_YX,$ which is a closed embedding as $X\rightarrow Y$ is separated, which is because $X$ and $Y$ are both separated, one being separated by definition, and the other being affine. (To see that $U\times_X V\rightarrow U\times_Y V$ is indeed a base change of $X\rightarrow X\times_YX$ along the map $U\times_Y V\rightarrow X\times_Y X$, just prove the universal property of fiber diagrams.)
Thus, we know that $U\times_X V\rightarrow U\times_Y V$ is a closed imbedding and that in particular, the induced map on global sections is surjective. But this is exactly the map in the problem, so we are done.