Temporary Files empty until pipeline closed

I have a pipeline that is defining a temporary file for output, hence is writing to: (LOCAL_PATH)\\{ppcCC7A8-8A70-49BC-815A-CFBBD77C405D}\\temp\\10C.tmp

Now I use the 'run command on server' component to execute a calculation which automatically writes output into: (LOCAL_PATH)\\{ppcCC7A8-8A70-49BC-815A-CFBBD77C405D}\\temp\\10C_output.txt

This node has the 'WaitForExit' flag set to TRUE.

Now I have a node to process the results using Perl script, so in the 'OnFinalize' section I have
open (SCORES, "<", \\\$ScoresFile);
my @raw_data=;
pilot::debugMessage(scalar(@raw_data));
close (SCORES);
where \\\$ScoresFile is set to the '10C_output.txt' file.

If I run the debugger, I get '0' reported as the scalar of the file contents array - ie nothing in it. However, if I navigate to the directory and open the file it is full of results.

If I manually set the \\\$ScoresFile to the same output in a copy of the directory, but hardcoded, it reads the data ok.

I'm guessing there is something keeping the file in 'open' state in my node, preventing me from reading it, but there is nothing else in my script except grabbing some global vars. Any ideas?