Fixed getline tp take corner cases into account.