Close old file and open new one if a new filename is passed in ref #3218
Merge pull request #3219 from bwspenc/table_output

Close old file and open new one if a new filename is passed in