This loop overwrites the existing line every time. It sounds like you have many lines. You will need to construct a vtkPolyData of lines instead.
The vtkPolyData has a set of points and cells (connectivity). You can construct vtkPoints and a vtkCellArray, give them to a vtkPolyData. Then write that vtkPolyData to a file.
In this example the pts is set to sets of quads (counter clockwise connectivity of 4 points). You will need sets of lines so yours would look more like: