Fixed a rather embarrassing bug that would see output lines interleaved when multiple workers are used. This has been corrected by using temporary SQL files and outputting them at the end, when STDOUT is desired.