Saves text file based on directory tree