Replace subprocess "check_output" with "Popen"