About the need to specify the enoding and how to find it

why we need to specify encoding while performing filewrite ?

We need to specify encoding sometimes since default in not utf-8 while working on windows.
This blog might be useful -

I hope I’ve cleared your doubt.
If you still have some questions or not find the answers satisfactory, you may reopen
the doubt.