fixed occasional sql bug
added check for existing file and auto output and flag to force redraw