text writing securtiy issue.

Ok so I'm working on a project that stores a number of users details and their associated mailing lists then after all edits writes all the .ali files to a directory.

I'm using the following code as a test of (Which I haven't used before).

txtout_file ="/export/machinename/htdocs/users/public/mailaliases/all.ali","w+") txtout_file << "Some random text" #write output to the file txtout_file.close #close the file

This should write the line "Some random text" to the file all.ali, and it does as long as all.ali already exists. If all.ali is not in the directory it fails with the following error "Permission denied - /export/machinename/htdocs/users/public/mailaliases/all.ali"

I was under the impression that the w+ mode would create a file if the file did not exist. The folder permissions are correct as far as I can see and yet I cannot get rails to create the all.ali file.

Any ideas?