Number of rational numbers in $A$

This proof looks good to me.

what is the justification of the line in bold?

Take a rational number $\frac ab$ which is not an integer. Assume it is written in simplest form. Then there is some prime which divides $b$ but not $a$. The same prime will divide $b^2$ but not $a^2$, showing that $\frac{a^2}{b^2}$ is not an integer.

Since non-integer rationals never have integer squares, integers can never have non-integer rational square roots.


When it is a rational number it has to be an integer. It cannot be anything else

For this, you can use the Rational Root Theorem

Consider the polynomial $x^2 - (n^2+2017)$ whose roots yield what you want. Here, $a_0 = n^2+2017$ and $a_n=1$. The theorem states that any rational root $x = \large{\frac{p}{q}}$ (in its lowest terms, i.e., $gcd(p, q) = 1$), will be such that $p\ |\ a_0$ and $q\ |\ a_n$.

Here since $a_n=1$, it clearly means $q=1$ and all hence $x \in \mathbb Z$