in reply to binmode layer and seek

Your logic is faulty (never binmode crlf)
read this