Fix queries not being logged correctly if an assertion failure is hit.

In QueryLoggingSolver call flush() on std::ofstream so that queries get correctly logged if an assertion failure is hit later on.