import os # Specify the file path file_path = "./status.txt" if os.path.exists(file_path): with open(file_path, 'r') as file: content = file.read().strip() if content == "running": print("file already running") exit() # Exit the program if the file already says "running" with open(file_path, 'w') as file: file.write("running") print("file status set to running")