added copy-to-clipboard feature and fixed trailing newlines bugs