ex20, defined functions and used them to read a file