But OP is not going to divert the output into `/dev/null`. In a Linux terminal you don't really gain much benefits from avoiding flushing because it will flush on a newline regardless. $ time cat bigfile.txt | ./mine ; cat -n mine.nim # ... real 0m3.707s user 0m0.662s sys 0m1.494s 1 import strutils 2 3 proc main() = 4 for ln in stdin.lines: 5 var i = 0 6 for f in ln.split('\t'): 7 if i == 4: 8 echo f 9 break 10 else: 11 inc(i) Run $ time cat bigfile.txt | ./krtekz ; cat -n krtekz.nim # ... real 0m4.328s user 0m0.654s sys 0m1.656s 1 import strutils 2 3 proc main() = 4 for ln in stdin.lines: 5 var i = 0 6 for f in ln.split('\t'): 7 if i == 4: 8 writeLine(stdout, f) 9 break 10 else: 11 inc(i) 12 13 main() Run $ cat -n filegen.nim 1 import os 2 3 var file = open(paramStr(1), fmWrite) 4 5 for lineNum in 0 .. 1000000: 6 for wordNum in 0 .. 10: 7 file.write(wordNum, '\t') 8 file.writeLine("") Run
* * * Ok I checked OP's code against the bigfile and it's around the same time in my machine (4.8s). All codes are compiled with the `-d:danger` flag. Python code is ~(4.1s) in my machine. I can't seem to figure out how do you guys get such varying numbers. All the codes provide the same output too.