The author went on and proved that
1) There exists no rational $p$ such that $p^2=2$
2) He defined two sets $A$ and $B$ such that if $p\in A$ then $p^2 <2$ and if $p\in B$ then $p^2>2$ and then constructed $$q=p - \frac{p^2-2}{p+2}$$ and $$q^2-2=\frac{2(p^2-2)}{(p+2)^2}$$
Then $A$ contains no largest element and $B$ contains no smallest element
Finally in the remark he said that the purpose of the above exercise was to show that the rational number system has certain gaps.
So my question is how is 2) used in arriving at this conclusion? I basically didn't understand the purpose of 2) in this discussion.
Suppose $A$ contained a largest element $p$. Now we have $p^2-2<0$. Then we must have $q^2-2=\frac{2(p^2-2)}{(p+2)^2}<0$ as the numerator on the right hand side is negative and the corresponding denominator positive.
So $q\in A$. However $q=p-(\mbox{negative quantity})$ i.e. $q=p+\mbox{positive quantity}$ by definition. So $q>p$ contradicting the $p$ was the largest element. So $A$ has no largest element. A similar argument works for $B$.