Refactor the read from file to support multiple types