revised data reading to use readline