Added flock (File-Locking) to generate key