Read repeated input from a file or stdin.