Number of rational numbers in $A$ 
Consider the set $A=\{\sqrt{2017+n^2}:n\in N\}$. How many numbers in the set A are rational?

My attempt:
The square-root of a non-negative integer can either be a rational number or an irrational number. When it is a rational number it has to be an integer. It cannot be anything else (I do not exactly know why but my mind says so). 
So by this logic, if $\sqrt{2017+n^2},n\in N$ is a rational number , it has to be a positive integer. Therefore, $2017+n^2=k^2$, for some $k\in N$. Therefore, $2017=(k+n)(k-n)$. Since $k,n\in N$, and $2017$ is a prime number, $(k+n)=2017,(k-n)=1$. This implies, $k=1009, n=1008$. Since we got one value of $n$, there is only one number is $A$ which is rational.
Is my reasoning and my answer right? If not then what is the correct reasoning and answer and if yes then what is the justification of the line in bold?

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.
