Fixed bugs in the readLine function