in reply to Re^2: Script no longer exiting
in thread Script no longer exiting

Looks suspicious, smells like some sort of text input problem. Can you try to append "\n" to the end of the $result, and see what happens?