Insert an ad into Views Grid?
Nice attempt, but no the template file is not the best place for that.

I would work on including the ads in your View result rather than trying to hack the template file.

Does your view show rendered content?  Easy, make a new content type that contains your ads and include that content type in your filter.

Does your view show fields?  Same thing, just make sure the ad content type has the same fields as the content you're showing in the grid.