I'm kinda new to NodeJS and I'm working on a simple file encoder.

I planned to change the very first 20kb of a file and just copy the rest of it.

So I used the following code, but it changed some bytes in the rest of the file.

Here is my code:

```
var fs = require('fs');
var config = require('./config');

fs.open(config.encodeOutput, 'w', function(err, fw) {
     if(err) {
        console.log(err);
    } else {
        fs.readFile(config.source, function(err, data) {
            var start = 0;
            var buff = readChunk(data, start);
            while(buff.length) {
                if(start < config.encodeSize) {
                    var buffer = makeSomeChanges(buff);

                    writeChunk(fw, buffer);
                } else {
                    writeChunk(fw, buff);
                }

                start += config.ENCODE_BUFFER_SIZE;
                buff = readChunk(data, start);
            }
        });
    }  
});

function readChunk(buffer, start) {
    return buffer.slice(start, start + config.ENCODE_BUFFER_SIZE);
}

function writeChunk(fd, chunk) {
    fs.writeFile(fd, chunk, {encoding: 'binary', flag: 'a'});
}

```

I opened encoded file and compared it with the original file.

I even commented these parts:

```
//if(start < config.encodeSize) {
//    var buffer = makeSomeChanges(buff);

//    writeChunk(fw, buffer);
//} else {
    writeChunk(fw, buff);
//}

```

So my program just copies the file, but it still changes some bytes.

What is wrong?