fix: added secure file writing