readline function implemented