Stabilizing effect of porosity on a flapping filament