line-based API fix for #211

see issue #211