[Tex/LaTex] How to get rid of these excessive rules

loopstables

enter image description here

\documentclass{article}%cannot be minimal
\usepackage{longtable}
\usepackage{ifthen, xspace}
\newcounter{xyz}
\setcounter{xyz}{1}
\def\and{&\xspace}
\begin{document}

\begin{longtable}{|*2{c|}}\hline
\whiledo{\value{xyz}<6}%
{\thexyz \and something\stepcounter{xyz} \\\hline}
\end{longtable}

\end{document}

Best Answer

This also removes the last two vertical lines:

\newcommand*{\condition}{\value{xyz}<6}
\begin{longtable}{|*2{c|}}\hline
\whiledo{\condition}%
{\thexyz \and something\stepcounter{xyz}%
\ifthenelse{\condition}{\\\hline}{\\\hline\end{longtable}}}

It's funny that these lines appear if I take \\\hline out of this \ifthenelse, similar if I put \end{longtable} after that (even with % before the line break). And, actually, I don't like ending an environment within a loop construction.