Fixed a bug when printing a query altered it