I think you're right - this is not a bug with Nim, but something to do with the buffer size for STDIN. You could try wrapping setvbuf and setting options on STDIN buffer size that way? maybe?
I get the same behavior with the Python script
from sys import stdin, stdout
input_eqn = stdin.read()
stdout.write(input_eqn)
giving weird results if I copy-paste directly (and working correctly if I cat
the input from a file and pipe it to the script).
