How to write to a separate PHP file in plugin settings

It is impossible especially if you also need to keep the key in secret. Just use the DB.