module Main where

import Text.Regex.Posix ((=~))
import System.Environment (getArgs)

myGrep :: String -> String -> IO ()
myGrep regex filename = do
  fileSlurp <- readFile filename
  mapM_ putStrLn $
    filter (=~ regex) (lines fileSlurp)

main :: IO ()
main = do
  (myRegex:filenames) <- getArgs
  mapM_ (myGrep myRegex) filenames
