Prevent negative array index access when a line solely consists of newlines and spaces

`len` can get decremented to -1 if the line is purely newlines and spaces.  Prevent negative array indices by resetting length to zero if it got decremented to -1.