Check that there's sql to print before printing extraneous newlines