Using `$pbcore->getContent($output_path);` would probably be simpler, instead of opening and closing the file pointer manually.