in reply to perl in DOS woes

binmode. The premature EOF will not be your only problem, conversion of CR+LF to bare LF will be another one. binmode() fixes both.

And use $n = unpack 'v', $twobytes; or maybe yet unlikely, $n = unpack 'n', $twobytes; to extract the 2 byte integer. 'v' is for Little Endian, default on Intel, while 'n' is for Big Endian.