let's take a look at those lines:
/31/ $file = fopen("ftp://fahhem:laks@fahhem.t35.com/usernames/".$user.".txt","a");
/32/ fclose ($file);
First off, you open the file via ftp for writing, and then immediately close it. I don't see any point of this.
Second, WHY FTP? Ftp takes longer than opening through the file system. If you do need to open that file for writing (it looks to me like you don't) Since it looks as though you are on the same machine, just open it like this:
fopen("/usr/home/freehost/26817/usernames/".$user.".txt","a");
According to your error, it's trying to open '...usernames/.txt'. That means that $user isn't defined. Files that begin with . are hidden files in unix, and you might not be able to open them via ftp.
Make sure $user is defined before you try to open a file called that.
Supplied argument is not a valid File-Handle resource: That happens because you haven't acually opened a file.
You should take some time to think about what your code is doing. Just go through, and try to figure out why it's not working before you post here. The error messages are sometimes cryptic, but in this case, they were pretty straight-forward.
Finally, you did give out your password on line 31, so you might want to change that before anyone logs in as you.