Use a generator to read file