'Opened empty txt file with notepad after write text to it

I have PySimplegui and I've written code that creates and write text to .txt file and after that is done I call subprocess to open that file with notepad, but file is empty.

I've using .close(), but seems that has no effect. When I go to check that file there is text, but when I open that file in GUI (written; PySimpleGUI) it's empty.

list_output = open(Path + '/list.txt', 'w')

# script.py writes some data to txt file and this part of code works fine...
subprocess.Popen(['python', Path + '/script.py'], stdout=list_output) 

list_output.close()

open_list = subprocess.Popen(["notepad", Path + "/list.txt"])


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source