use for-loop instead of using ftell for every sample