Make countlines function polymorphic and remove countplain