The target file can be a file or stdout if no file is specified.