Refactor line printing