I guess the curl script fails due to 301 redirect. Modifying.