added debug output to try and track down negative lineindex issue, can't reproduce yet