I was accidentally removing the last element in the points array which sometimes was '\r\n', now fixed