Using default buffer size.
Typo fix.
Using autodetection only when tjere is no encoding set.
Using readline function.