/// <summary>
        /// Outputs a GedcomDatabase to the passed stream.
        /// </summary>
        /// <param name="database">The GedcomDatabase to write.</param>
        /// <param name="stream">The stream to write to.</param>
        public void WriteGedcom(GedcomDatabase database, Stream stream)
        {
            Encoding enc = new UTF8Encoding();

            using (var writer = new GedcomStreamWriter(stream, enc, 1024, true))
            {
                Write(database, writer);
            }
        }
        /// <summary>
        /// Outputs a GedcomDatabase to the given file.
        /// </summary>
        /// <param name="database">The GedcomDatabase to write.</param>
        /// <param name="file">The filename to write to.</param>
        public void WriteGedcom(GedcomDatabase database, string file)
        {
            Encoding enc = new UTF8Encoding();

            using (var writer = new GedcomStreamWriter(file, false, enc))
            {
                Write(database, writer);
            }
        }
        /// <summary>
        /// Writes the specified database to the passed writer.
        /// Not for use outside this class as the writer must be
        /// responsibly disposed in a using block by the caller.
        /// </summary>
        /// <param name="database">The database to write.</param>
        /// <param name="writer">The writer to use for outputting the database.</param>
        private void Write(GedcomDatabase database, GedcomStreamWriter writer)
        {
            writer.AllowInformationSeparatorOnSave = AllowInformationSeparatorOnSave;
            writer.AllowLineTabsSave = AllowLineTabsSave;
            writer.AllowTabsSave     = AllowTabsSave;

            database.Header.Output(writer);

            // write records
            foreach (DictionaryEntry entry in database)
            {
                var record = entry.Value as GedcomRecord;

                record.Output(writer);
                writer.Write(Environment.NewLine);
            }

            writer.Write(Environment.NewLine);
            writer.WriteLine("0 TRLR");
            writer.Write(Environment.NewLine);
        }