updated function to read text file