With Mixin::Linewise::Readers and Mixin::Linewise::Writers, you can just write a method to handle handles, and methods for handling strings and filenames are added for you. WWW: https://metacpan.org/release/Mixin-Linewise