public MutableString ReadLine(MutableString/*!*/ separator, RubyEncoding/*!*/ encoding, bool preserveEndOfLines, int limit) {
// TODO: limit
int b = ReadByteNormalizeEoln(preserveEndOfLines);
if (b == -1) {
return null;
}
int separatorOffset = 0;
int separatorLength = separator.GetByteCount();
MutableString result = MutableString.CreateBinary(encoding);
do {
result.Append((byte)b);
if (b == separator.GetByte(separatorOffset)) {
if (separatorOffset == separatorLength - 1) {
break;
}
separatorOffset++;
} else if (separatorOffset > 0) {
separatorOffset = 0;
}
b = ReadByteNormalizeEoln(preserveEndOfLines);
} while (b != -1);
return result;
}