write temporary queries into a temp file