refactor filehandle reader