fixed write-to-file mode