Update main.js

saving writer instance