I have read that you must use CURLOPT_RETURNTRANSFER ,1 when doing it that way. Otherwise it sends it to the browser.

I never use it that way myself. I always use fopen to get the remote file , read and save it.