fixed closing egrep input twice