Extracted the reading part into a method
Added a method to deal with text files
Treating text files differently