Use .bat ext for local script files on windows #546
Fix invalid read offset due to windows line endings #532

using crlf (dos) endings caused reader to read two lines, and
set byte offset to be 2 greater each time. when read buffer
ends the next requested offset could incorrectly start mid line.

* use only lf endings, add one byte per line
* avoid npe if offset is invalid