Use filter instead of list comprehensions

Also, use `/= ' '` instead of `not (`elem` " ")`.