fix outputting to existing directory