Fixes formatting issue with directories
Now can write out to file, select directories or files