Implement it instead on split_line() as noted by sebth so that it doesnt need to be repeated on two places.