readup on chown, chgrp, and chmod.. anyways about security, try putting the file under the public_html folder (or www, whatever) this way only your scripts can access it and it helps prevent people from messing with it
i could be wrong, but if you chmod it to 777 it changes group/owner to nobody right?