Fixed a bug about file-writing.