Yes it doesnot affect the value of the integral. But the method can be proved wrong mathematically ( method followed after dividing by cos2x )
According to Fundamental Theorem of Calculus, the integrand must be continuous on [a, b], which is what you do when you find an antiderivative for f and evaluate it at the two endpoints. Otherwise you are dealing with an improper integral. If f is not defined at the endpoints (or at points inside the interval), you must use limits to evaluate the integral which the author doesn't mention/use.