Added a flag to indicat compression since to_file is using temporary file with fixed name