improved file reader