main :: IO ()
main = do
arg <- getArgs
case arg of
[from,to] -> do
content <- readFile from
`catch` (\_ -> fail $ "file does not exit: " ++ from)
writeFile to (filter (== '\n') content)
`catch` (\_ -> fail $ "could not write to file: " ++ to)
_ ->
fail "invalid arguments. use <fromfile> <tofile>"
This has the advantage of actually being fast: [code]$ wc irc/Updike\,\ John\ -\ Rabbit\,\ Run\(v1.1\)\[htm\].html
11617 102746 615253 irc/Updike, John - Rabbit, Run(v1.1)[htm].html
$ time ./whut irc/Updike\,\ John\ -\ Rabbit\,\ Run\(v1.1\)\[htm\].html blah