Also, this part:
while(!%file.isEOF())
{
%string = %string SPC %file.readLine();
}
Should turn into:
while(!%file.isEOF())
{
%string = %string $= "" ? %file.readLine() : %string SPC %file.readLine();
}
So that the first character of %string isn't a space.