When running code in the console, any result that it not explicitly made invisible will be printed. When you run the if block, only the last result will be shown (in this case, nothing, though file.show will open the document). You need to explicitly call print(...) to make sure something's printed.
That said, sink can be good for logging script progress, but it's not something to rely on for writing specific objects to files. writeLines is good for that.
if (interactive()) {
tmp <- tempfile(fileext = '.txt')
uniques <- lapply(raw, unique)
writeLines(as.character(uniques), tmp)
file.show(tmp)
}
The text file's contents will look like c("foo", "bar", ...), but hopefully that's good enough for checking.