in reply to problem opening and reading from a file

I think that you may you need to put a semi-colon at the end of your code:
print OUT "foo,bar,totally foobar\n"
ie like this:
print OUT "foo,bar,totally foobar\n";
John