Preserve line endings while filtering

The current implementation of the filter replaces all line endings of input files with the platform-specific variant. For example, this leads to problems with shell scripts on the Docker host, if the library is used on
Windows. The changed filter algorithm preserves the line endings.