Here is a different approach by Lagrange Interpolation. Let $\mathcal{A}=\{a_1,a_2,\ldots,a_n\}$ be values such that $f(a_i)\in\mathbf{Z}$ for $a_i\in\mathcal{A}$. Let $f(a_i)=k_i$, $1\le i\le n$. Now, consider the polynomial defined by $$g(x)=f(x)+\sum_{i=1}^{n}\frac{(x-a_1)(x-a_2)\cdots(x-a_{i-1})(x-a_{i+1})\cdots(x-a_n)}{(a_i-a_1)(a_i-a_2)\cdots(a_i-a_n)}(-k_i).$$ Clearly $g(a_1)=g(a_2)=\cdots = g(a_n)=0$, so $g$ has roots everywhere in $\mathcal{A}$. Thus, we can write $g$ as $$g(x)=c(x-a_1)(x-a_2)\cdots (x-a_n).$$ Now, consider $g(a_{n+1})$. Then, $f(a_{n+1})\in\mathbf{Z}$ and $$\sum_{i=1}^{n}\frac{(a_{n+1}-a_1)(a_{n+1}-a_2)\cdots(a_{n+1}-a_{i-1})(a_{n+1}-a_{i+1})\cdots(a_{n+1}-a_n)}{(a_i-a_1)(a_i-a_2)\cdots(a_i-a_n)}(-k_i)\in\mathbf{Q}.$$ It follows, due to how we defined $g$ and closure of $\mathbf{Q}$ over addition, that $g(a_{n+1})\in\mathbf{Q}$. Then, we have $$g(a_{n+1})=c\prod_{i=1}^{n}(a_{n+1}-a_i)\in\mathbf{Q},$$ so be closure of $\mathbf{Q}$ under multiplication we know that $c\in\mathbf{Q}$. The value of $c$ is invariant to the value $g$ takes, so it follows that $g(x)\in\mathbf{Q}[x]$, and so $f(x)\in\mathbf{Q}[x]$ as well.