Fixing bug: name of directory as output file