I do something like this, but as an extra step I have the program check the permissions on the file and refuse to use it if it's readable by anyone but the owner. It's too easy to negligently not set the correct permissions or change them incorrectly at some later point and having the program fail, with a message, helps to protect you here.