Fixed fgetc problem, modified fclose prolog predicate. create_lock tests if the lock already exists before to try create or truncate it