read using readline, some fixes