Why doesn't electric flux depend on a charge outside the surface? Let us assume a gaussian sphere with zero charges inside it, then the flux will also be zero in accordance to Gauss' law. But if we have  a charge or many charges outside the sphere such that the electrical field lines of that charge passes through the sphere, then we definitely have electrical flux on the surface. But this contradicts Gauss' law that the electrical flux depends on the charges inside the sphere. Here is a picture for reference...

Here you can see that the charge outside the sphere has some of its electrical field lines going through the surface. Thus there must be some electric flux on the sphere, right?
My question arises when we were learning about the electric field inside a spherical conductor with charges (many charges) on its surface. My textbook tells me that since the sphere encloses no charge because all the charge inside the conductor comes onto the surface, the electric flux is zero. Thus the electric field is also zero. But my question is why isn't the charges outside the sphere contributing to the electric flux?
 A: Because every field line that enters the surface exits it.
One can think of electric flux as being a way of counting how many field lines are crossing the surface, with the distinction that field lines crossing the surface in opposite directions count with different signs. As you correctly reasoned, the field lines of charges outside the closed surface will enter the surface, and hence contribute to the total flux. However, they will also need to exit the surface somewhere: electric field lines can only start and end at charges, so since the surface is not enclosing any charges they have no option rather than getting out of the surface somewhere else. As a consequence, for every field line entering the surface you get a field line leaving the surface, so they cancel each other out.
If there was a charge enclosed by the surface, the field lines would be able to terminate at the charge, so that they could leave the surface without ever entering it (for a positive charge), or enter the surface without ever leaving it (for a negative charge).
