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?
 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.
A: 
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$
A: $2017+n^2 = \frac{a^2}{b^2} \iff (2017+n^2)b^2 = a^2$
Recall if $a^2k$ is a square then $k$ is a square so $2017+n^2=s^2$ for some $s$. 
Now we have $2017 = (s-n)(s+n)\implies s-n=1$ since $2017$ is prime. 
We conclude $s=n+1$ and so $2017 = s+n = 2n+1\implies n = 1008$
A: So, what is needed here is:
(A.)  If $n \in \Bbb N$ is not a perfect square, then $\sqrt n \notin \Bbb Q$.
We can see this as follows:
Let $\sqrt n \in \Bbb Q \setminus \Bbb Z$; then
$\sqrt n = \dfrac{r}{s}, \; 0 < r, s \in \Bbb Z; \tag 1$
we may assume that
$\gcd(r, s) = 1; \tag 2$
we note that
$s \ne 1, \tag 3$
lest (1) affirm that
$\sqrt n = r \in \Bbb Z; \tag 4$
from (1),
$r^2 = ns^2; \tag 5$
in light of (3), there exists some prime $p \ge 2$ with
$p \mid s \Longrightarrow p \mid s^2 \Longrightarrow p \mid r^2 \Longrightarrow p \mid r \Rightarrow \Leftarrow \gcd(r, s) = 1; \tag 6$
thus we see that the assumption (1) yields contradictory results; hence 
$\sqrt n \notin \Bbb Q. \tag 7$
This demonstration of course hearkens unto the famous proof presented by Euclid in his Elements, Prop. 117, Book X, and justifies the "line in bold" presented in the text of the question.
Having established (A), the remainder of our OP MrAP's proof that the only integer in the set
$A = \{ \sqrt{2017 + n^2}: n \in \Bbb N \} \tag 8$
is $1009$, corresponding to $n = 1008$, successfully falls into place.
