Added handling of 3-line printing, fixed segmentation fault