Updated worker to write out file to result folder