applescript copy paste between textedit and 3rd party application not working
<p>I have searched all over this site and cannot find an answer to why this code isn't doing what I need it to do. I have a textedit doc with a list of numbers. I want to copy 1 number at a time paste that number into a 3rd party application at a specific place in url, and then hit some buttons in the ui of that application. I need this process to repeat for each individual number in the textedit document. </p>

<p>Here is what I came up with after researching applescript. </p>

<pre><code>tell application "TextEdit" to activate
tell application "System Events"
    tell process "TextEdit"
    key code 124 using {shift down, command down}
    keystroke "c" using command down
    key code 125
end tell
end tell

delay 1.0

tell application "import.io" to activate
tell application "System Events"
    tell process "import.io"
        keystroke tab
        keystroke tab
        key code 124
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 123
        key code 51
        keystroke "v" using command down
        keystroke tab
        key code 76
    end tell
end tell



-- Make a selection from the popupbutton.
delay 2.231426
set timeoutSeconds to 10.0
set uiScript to "click pop up button 1 of window \"Save\" of application process \"import.io\""
my doWithTimeout(uiScript, timeoutSeconds)
return input
end run


on doWithTimeout(uiScript, timeoutSeconds)
    set endDate to (current date) + timeoutSeconds
    repeat
        try
            run script "tell application \"System Events\"
                " &amp; uiScript &amp; "
                end tell"
            exit repeat
        on error errorMessage
            if ((current date) &gt; endDate) then
                error "Can not " &amp; uiScript
            end if
        end try
    end repeat
end doWithTimeout


-- Click the “&lt;fill in title&gt;” checkbox.
delay 1.496275
set timeoutSeconds to 10.0
set uiScript to "click checkbox 1 of window \"Save\" of application process \"import.io\""
my doWithTimeout(uiScript, timeoutSeconds)
return input





-- Type “Data” into the text field.
delay 7.290406
set timeoutSeconds to 10.0
set uiScript to "click text field 1 of group 17 of list 1 of scroll area 1 of scroll area 1 of browser 1 of splitter group 1 of splitter group 1 of group 2 of window \"Save\" of application process \"import.io\""
keystroke "Data"
keystroke "."
tell application "System Events" to tell process "import.io"
    keystroke "v" using command down
end tell
my doWithTimeout(uiScript, timeoutSeconds)
return input




-- Click the “Save” button.
delay 1.475013
set timeoutSeconds to 10.0
set uiScript to "click UI Element \"Save\" of window \"Save\" of application process \"import.io\""
my doWithTimeout(uiScript, timeoutSeconds)
return input

my textedit document is formatted like this:
50
100
150
200
etc

When I run the script this is what it does to my textedit document: 

50
50
    100
150
200
etc
</code></pre>

<p>Any idea what is going on here? I can't make heads or tails of it. </p>