fixed check for number of bytes transferred (Thanks, Jared!)