code: func CopyToFile(outfile string, r io.Reader) error {
  	// We use sequential file access here to avoid depleting the standby list
  	// on Windows. On Linux, this is a call directly to ioutil.TempFile
  	tmpFile, err := system.TempFileSequential(filepath.Dir(outfile), ".docker_temp_")
  	if err != nil {
  		return err
  	}
  
  	tmpPath := tmpFile.Name()
  
  	_, err = io.Copy(tmpFile, r)
  	tmpFile.Close()
  
  	if err != nil {
  		os.Remove(tmpPath)
  		return err
  	}
  
  	if err = os.Rename(tmpPath, outfile); err != nil {
  		os.Remove(tmpPath)
  		return err
  	}
  
  	return nil
  }
docs: // CopyToFile writes the content of the reader to the specified file