Refactor the renderFile function to a generator function #3