Added check for missing filename.
Made controller run query on publish if output is empty.