Added GetFileExtension function and applied if to several file reading functions.