Minor bug fix to recent locking commit

Permissions were being set incorrectly when writing the creds file
Implemented EOF