Changed to interact function

interact takes a function String -> String and call it with stdin
and send the result to stdout, simplifying the implementation and
allowing the program to take part in any shell pipeline.