As already mentioned, writing to the terminal is almost definitely going to be slower. Why?
Writing to the terminal uses line buffering
* by default. This means the contents of the buffer are transmitted everytime a newline is encountered. When writing to a file, the buffer is flushed only when the buffer becomes full or when you flush the stream manually. This is the main reason for the difference as the number of I/O operations is significantly different.
*: This is true for Unix implementations, but other implementations may be unbuffered (see discussion in comments).
When you write to a terminal, this involves rendering on the screen, and depending on the terminal could involve other operations that can slow your program down (not all terminals are made the same, you might find significant differences in speed by just switching to a different one).