If there's an error reading original file, then there's no sense in attempting to write to new file, so you should add this condition:

```
    if (!readError) {
        // your code here...
    }
```