fix line ending not adding an extra one
adding support for stripping Byte Order mark (aka BOM)