added filename-return-option to write() function