Checking for < end_port instead of <= end_port, so end port wasn't inclusive, fixed.