added functions to check file extention for csv and run appropriate read/write function for csv or text