changed the subprocess call to have stdout piped to file