Extract method to read from input