Added: Appropriate error checking and writing to the clipboard.