Refactoring read_file function to allow returning a list