title: read stream & direct stream into file in typescript
body: <p>I am using node with typescript.</p>
  <p>I need to read large file as stream and direct write it into file using typescript with node js.</p>
  <p>It is giving me error .</p>
  <p>Error : The &quot;data&quot; argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Object</p>
  <pre><code>import * as fs from 'fs';
  import { createReadStream, writeFile } from 'fs';
  const { createServer,http } = require('http');
  var parse = require('csv-parser');
  var csv = require('fast-csv');
  const options = { headers: true, quoteColumns: true };
  const { writeToPath } = require('@fast-csv/format');
  const { convertArrayToCSV } = require('convert-array-to-csv');
  
  try {
  
     var csvData= [];
     const stream = createReadStream(__dirname+'/content/readsample1.csv', { 
                   highWaterMark: 9000, encoding: 'utf8'});
     stream.pipe(parse({}))
     .on('data', (csvrow: any)  =&gt; {
         console.log(csvrow)
         fs.writeFileSync(__dirname+'/content/someDatas1.csv',csvrow, { flag: 'a' })
     })
     .on('error', () =&gt; {
        console.log(&quot; in console error &quot;)
     })
     .on('end', () =&gt; {
         console.log('done')
     }) 
  
    } catch (err) {
  
     console.error(err)
   }
  </code></pre>
  <p>Can anyone help me how to overcome from this ?</p>