STREAM FILE exits immediately

I’ve been going crazy trying to make STREAM FILE work to play a file. The response from the server never comes before the script exits. I have to place a sleep in the script to catch the response. Without the sleep it blows right pas checkResponse. If I use EXEC PLAYBACK it works fine except you can’t have interrupt keys. Not sure where I’m going wrong. checkResponse is from picotts.agi.

print "STREAM FILE /tmp/myfile \"\" \n";
my @response = checkresponse();

sub checkresponse {
    my $input = <STDIN>;
    my @values;

    chomp $input;

    if ($input =~ /^200 result=(-?\d+)\s?(.*)$/) {
        warn "$name Command returned: $input\n" if ($debug);
        @values = ("$1", "$2");
    } else {
        $input .= <STDIN> if ($input =~ /^520-Invalid/);
        warn "$name Unexpected result: $input\n";
        @values = (-1, -1);
    return @values;