Improper usage of Popen