Flat morphism of affine schemes 
If $U=\text {Spec} \ B$ is an open subset of $X=\text{Spec}\ A$, why the restriction $f:A\to B$ is flat?

I took this from the book Algebraic Geometry and Arithmetic Curves.
My attempt is for a closed multiplicative set $S$ of $A$, then $S^{-1}A$ is flat over $A$. Now consider a prime $q$ of $B$, let $p=f^{-1}q$, then $B_q=(B\otimes_A A)_p$ which is flat over $A_p$, and the result follows. Am I correct?
 A: Your proof seems to be lacking in details. 
Working thru Liu's Algebraic Geometry and Arithmetic Curves, here is the proof I found:
We have an open immersion of schemes $f:U\to X$. By definition of open immersion of schemes (see definition 3.13 in section 2.3 and definition 2.22 in section 2.2) we get an isomorphism of stalks $f_{\mathfrak{q}}^\#:\mathcal{O}_{U,\mathfrak{q}}\xrightarrow{\cong} \mathcal{O}_{X,f^{-1}(\mathfrak{q})}$ for all $\mathfrak{q}\in U$. It follows that $\mathcal{O}_{U,\mathfrak{q}}$ is flat over $\mathcal{O}_{X,f^{-1}(\mathfrak{q})}$ for all $\mathfrak{q}\in U$. 
Since $U=\text{Spec}(B)$ and $X=\text{Spec}(A)$ are affine schemes we have that $\mathcal{O}_{U,\mathfrak{q}}=B_{\mathfrak{q}}$ and $\mathcal{O}_{X,f^{-1}(\mathfrak{q})}=A_{f^{-1}(\mathfrak{q})}$ (by Proposition 3.1(b) of section 2.3). 
By the previous two paragraphs, $B_\mathfrak{q}$ is flat over $A_{f^{-1}(\mathfrak{q})}$ for all $\mathfrak{q}\in U$. By a commutative algebra result (Corollary 2.15 of section 1.2) this implies that the restriction $A\to B$ is flat.
