Improve copy-line function