You could use print and then redirect output:
script.js:
cursor = db.users.find();
while(cursor.hasNext()){
printjson(cursor.next());
}
then run the script and redirect output to a file:
mongo --quiet script.js > result.txt
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…