(VTK.js) How to add multiple polylines in vtkPolyData

I have multiple lines that defines an object and I need to present them in VTK. I figured out how to do that in VTK.js and vtkPolyData, by adding all points of all lines and defining the lines. The problem is that the last point of the previous line is connected to the first one of the actual line. How could I separate the lines?

function createPolyData(pointsList) {
const pointList = roiData.pointsList;
const polygon = vtkPolyData.newInstance();
const pointArray = [];
let index = 0;

const lines = vtkCellArray.newInstance();

for (let i = 0; i < pointList.length; i++) {
const points = pointList[i].points;
const lineArray = [];
for (let j = 0; j < points.length; j++) {

  lineArray.push(index + j);
// Uniting the last point with the first
index = index + points.length;

polygon.getPoints().setData(Float32Array.from(pointArray), 3);

const mapper = vtkMapper.newInstance();

const actor = vtkActor.newInstance();
return actor;

I didnt know how to use the vtkCellArray. After I found one example, I applyed to my problem and it works!!! I am sharing the code here of my function…