This is the code I’m running: Before pressing a key, I’m trying to delete the file manually in FAR Manager. But FAR says that the file is locked: Only after pressing a key, the application terminates and I can delete the file. What is wrong with my code? Answer Try this one.