Fix a bug in sample window function.

The currentPosition should be incremented in all cases.