You need to add 1 to those offsets because the PUT- functions are (inexplicably) 1-based instead of zero-based. Continue reading...