Bugfix to many element for lines

BUG: infinite loop if more elements than lines