Can gauss law for magnetism be used for open surfaces? Suppose there's a loop of current carrying wire in a plane,then it's stated in my book that magnetic flux through the area of loop will be negative and of equal magnitude as the flux outside the loop and in the plane.The reason given is supposedly following gauss law, "since magnetic field lines are closed loops each field line crosses both inside and outside loop, so flux is same".This is highly unsatisfactory for me because firstly to the best of my knowledgeable gauss law is used for closed surfaces and not for planes, secondly it doesn't make sense just because "lines pass through both regions" will necessarily mean flux is equal,afterall lines are just imaginations and flux is dot product of field and area vector,how exactly will the dot products in both regions be equal,to be specific?
 A: One has to be very careful when trying to apply Gauss's law to open surfaces. Usually, you need to see the open surface as the limit of a closed surface.
In our case, you can consider a half-sphere having the same center as the loop, and imagine its surface as the radius of the half-sphere goes to infinity: the flat circular part of the surface becomes a plane, so we need to show that the flux through the hemispherical part goes to zero as the radius goes to infinity.
It can be shown this way: as the radius $R$ grows, the area of the hemisphere grows as $R^2$; on the other hand, at great distance from the current loop, its magnetic field is that of a magnetic dipole, that decays as $1/R^3$. Then the flux of the field through the hemisphere goes as $R^2\cdot 1/R^3 = 1/R$, and this means that as $R$ goes to infinity, the contribute to the flux coming from the hemisphere goes to zero.
Since the flux through the hemisphere goes to zero, we can discard it and apply Gauss's law to the plane only.

Anyway, you can also give a precise meaning to the flux lines. In particular you can show the validity of the following statement:
If $S_1$ and $S_2$ are two surfaces such that every magnetic field line going through $S_1$ crosses also $S_2$ and vice versa, then the flux of the magnetic field through the two surfaces is the same.
To convince yourself of this fact, consider all the field lines going through a finite surface $S_1$. They occupy a portion of space that is called a flux tube (follow the link to Wikipedia for a useful visualization). The surface of this region of space is such that the magnetic field is parallel to it in every point. It is clear that $S_1$ is a section of this flux tube. And it is also evident that every surface $S_2$, that is to satisfy the hypotheses of the previous statement, has to be a section of the same flux tube.
Then we can consider the closed surface made by $S_1$, $S_2$ and the "lateral surface" of the flux tube comprised between $S_1$ and $S_2$. We can apply Gauss's law to this closed surface. The flux through the lateral surface is zero because there the field is by definition parallel to the surface. So, in order for the total flux to be zero, the flux through $S_1$ must cancel out with the flux through $S_2$.
