readline and allocate and free dynamic memory