combined Gus' code and my code to read from file.