Fixed a bug in writing the results of the construct query to file