I'm reading text from a big file and write some parts into a new text file:
var ws = fs.createWriteStream('output.txt', {flags: 'w',encoding: 'utf8'});
for (var i = 0; i < words.length; i++) {
ws.write(words[i][0].toString() + "\t" + words[i][1].toString() + "\n");
}
ws.close()
However, if I open the created file, the editor (EDIT: xed on linux) refuses to open it. It says that there is something with the encoding. What can I do? Sanitize the string before writing? But how would I do that? Which symbols are problematic for a write stream?