Fixes #24 by initialising maxPos and returning -1 when no bytes remaining.