Added line length handling, rows and cols