first off, you don't use file() to make a file, you use touch('filename');
second, yes... you need permission to write to a directory. I suggest logging in on SSH and making your script a nice little dir to play with.
%mkdir dirName
%chown nobody dirName
%chgrp nobody dirName
PHP (nobody) will have the ability to read and write to that directory as often as it pleases.