in reply to problem opening and reading from a file

Well I can't tell since you didn't post all of your code, but shouldn't print OUT "foo,bar,totally foobar\n" have a semicolon? This could just be a cut-n-paste error, though.