Where have you placed password.txt?

Generally, if you have not used os.chdir, files try to open from the main script library. If you have placed it in a folder, or if you are running anything that used chdir, you are best off using absolute paths, or expanded from the user path

os.path.expanduser('~/Documents/your_folder/password.txt')