Is there a program with which I can create new text file, set password for it and every time I want to open it, I need to write correct password or otherwise file will not open and remain encrypted.
You can try Notepad3 from Rizonesoft: https://www.rizonesoft.com/downloads/notepad3/
It is a lightweight and fast editor for coding.
There used to be LockNote for it. However, this is no longer maintained. But if you look for alternatives, you will find many applications for exactly this purpose. There is even a plugin for Notepad++ called NPPCrypt if you use Windows.