save query to file