Damn, I should have spoted that 'Q' typo. The 'Q' should be passed as a key press instead of a button press. I'll update the code correcting that.
Regarding the cut and paste aspect. I didn;t really think about doing it any other way. I suppose I could have now that you say it, but this is the quickest and easiest(although not always the right, as you pointed out) way to do this.