Changed file handling and broke the reading into separate function for conversion into a class