Why is the electric flux through a surface between a dipole zero 
In surface $S_3$, as per the Gauss Law, the net electric flux is zero as there is no charge enclosed in the surface. Also the other reason the book mentions for this that since the amount of flux entering is equal to the amount leaving, the net flux is zero. Also the book say or every closed surface in an external field is zero. But flux is the measure of the field lines (electric field intensity) passing through a surface. Even if the Gaussian surface near a charge that itself doesn't contain the charge has the electric field lines passing through it. So shouldn't it have some flux rather than it being zero?
 A: 
Even if the Gaussian surface near a charge that itself doesn't contain
the charge has the electric field lines passing through it. So
shouldn't it have some flux rather than it being zero?

Yes there is electric flux. But there's a difference between electric flux and net electric flux. Gauss' law says that the net electric flux across a closed surface equals the (net) charge enclosed divided by the electrical permittivity of the space.
While there is electric flux across surface $S_3$, the net flux across surface $S_3$ is zero. Similarly, there is electric flux across the surface $S_4$, but the net flux across surface $S_4$ is zero, assuming the magnitude of the positive and negative charge is the same for a net charge of zero.
The magnitude of the electric flux, $\Phi_{E}$, through an area is defined as the electric field multiplied by the area of the surface projected in a plane perpendicular to the field, or
$$\Phi_{E} = \overrightarrow E\overrightarrow Acos\theta$$
Where $\overrightarrow E$ is the electric field vector (an electric field line), $\overrightarrow A$ is a vector normal to and of magnitude equal to the area facing outward from the area, and $\theta$ is the angle between. For further details, see the following: http://hyperphysics.phy-astr.gsu.edu/hbase/electric/gaulaw.html
So looking at surface $S_3$, since the direction of the the electric field lines coming in at the top is opposite to the direction of the outward facing area vector, the electric flux is negative. At the bottom, each line exits in the same direction as the outward facing area vector, so the electric flux is positive. Since every line that enters the enclosed space exits it as well, the sum of the positive and negative flux, the net flux, is zero.
Hope this helps
