If you happen to be on a unix/linux system (which is pretty much the only place where
chmod makes sense), you should be aware that chmod will fail when used on a file that is not owned by the user who is running the script. (update: unless of course the user happens to be "root" -- in which case the user really ought to know what s/he is doing...)
As mentioned above, checking the return value (and printing the value of $! when chmod returns false) will help you figure out what is going on.