Extra row appearing in table assembled in pgf for loop

I can understand the wish for using as less packages as possible; but when you load pgfplots you're already loading a huge amount of code. So it's not clear why relying on self-made methods for printing a table, when packages that already do it better are available.

\documentclass{article}
\usepackage{siunitx}
\usepackage{pgfplots}

\pgfplotsset{compat=1.9, /pgf/declare function={F(\x)=(\x+5)*(\x-1)*(\x-5);}}

\newcommand\foreachappendto[2]{%
  \xdef#1{\unexpanded\expandafter{\temp}#2}%
}
\begin{document}
$f(x)=(x+1)(x-1)(x+5)$

\medskip

% Build the table body outside the table
\gdef\temp{}
\foreach \kk in {1,...,5}{
  \pgfmathparse{2*\kk-6}%
  \foreachappendto\temp{\pgfmathresult&}%
  \pgfmathparse{F(\pgfmathresult)}%
  \foreachappendto\temp{\pgfmathresult\noexpand\\}%
}
\begin{tabular}{
  S[table-format=-1.1]
  S[table-format=-2.1]
}
\hline
{\boldmath$x$} & {\boldmath$f(x)$} \\
\hline
\temp
\hline
\end{tabular}

\end{document}

enter image description here