Why do you go here with len(data) - and above with reader.len ?
Is there a reason not to go with reader.len here as well?