Extract readFile method