May I suggest that you perform this check and set a bool member variable upon open(), rather than rifling through the attributes for every scanline?