Fix some bugs and add function for reading whole line.