in reply to concatenate directories and files into one csv

You open the file for reading instead of appending.

open FILE2,">>","$root";