Use cURL follow-redirects instead of manual looping forever.

Use cURL follow-redirects instead of manual looping forever. Closes #18. Closes #5.

I also moved the logging and header status setting up above the error checking.