Isn't the input expected to be a file-like object (e.g., ``StringIO`` or ``file``)? If it is already a list of strings, then the cast to list is extraneous. Regardless, there isn't a good reason for this code to walk over the full data 4 times when a single walk should suffice