Edit:@tjohnson this is in response to your comment. I don't have enough points to respond to your comment directly or something? Thanks Stack Overflow...
It's hard to say without seeing more of the code.
What version of Nim are you using?
I suspect stdout has been shadowed by a read only symbol.
Are you calling this code inside of a proc and passing stdout as an argument?like this:proc foo(stdout: File)
If so, you will need to change it to a var parameter to make the argument writable:proc test(stdout: var File)
Or use stdout as a global variable instead.