A cube is placed in a non-uniform field, where the field is decreasing from left to right. So in this case, when you calculate flux on the left and right side of cube (of side $A$) using $E\cdot A$, the flux is not going to cancel as $E$ will be different for left and right surfaces.
So in this case, a closed surface placed in a field will not have zero net flux. Where am I making mistake? If I use the concept of line $f$ forces that net flux becomes zero as whatever line of force is coming in has to go out.