replaced read with readline so the thread doesn't end prematurly