Added locking of the log file when opened