Fix infinite loop when trying to lock a file that doesn't exists and was been locked for writing.