Fixed an off-by-one like overflow which corrupted received files.