# Handle error events on file streams The `writeAsJsonFromFile()` and `toJsonFromFile()` functions need to close the file stream on `error` events to prevent memory leaks.
Handle error events on file streams
The
writeAsJsonFromFile()andtoJsonFromFile()functions need to close the file stream onerrorevents to prevent memory leaks.