Fixed a bug that occured when the number of lines was not a multiple of 3