Remember to do a file_set_status($file, FILE_STATUS_PERMANENT) or the file will only be temporary and be deleted on the next cron run. I will merge the PR and add the line :-)

See http://api.drupal.org/api/drupal/includes!file.inc/function/file_set_status/6