/// <summary>
        /// Writes formats from list.
        /// </summary>
        /// <param name="profiles"></param>
        /// <param name="skipRemoved"></param>
        /// <exception cref="System.ArgumentException">If attempt to write record without fields was made.</exception>
        /// <exception cref="System.IO.IOException">If an I/O error occurs.</exception>
        /// <exception cref="System.InvalidOperationException">Can't format profile field.</exception>
        private void WriteFormats(IList <InstrumentProfile> profiles, bool skipRemoved)
        {
            HashSet <string> updated = new HashSet <string>();

            for (int i = 0; i < profiles.Count; i++)
            {
                string type = types[i]; // atomically captured
                if (REMOVED_TYPE.Equals(type) && skipRemoved)
                {
                    continue;
                }
                InstrumentProfile ip = profiles[i];
                HashSet <InstrumentProfileField> enumFormat;
                HashSet <string> customFormat;
                customFormats.TryGetValue(type, out customFormat);
                if (!enumFormats.TryGetValue(type, out enumFormat))
                {
                    updated.Add(type);
                    enumFormat = new HashSet <InstrumentProfileField>();
                    enumFormat.Add(InstrumentProfileField.SYMBOL);
                    // always write symbol (type is always written by a special code)
                    enumFormats[type]   = enumFormat;
                    customFormat        = new HashSet <string>();
                    customFormats[type] = customFormat;
                }
                if (!REMOVED_TYPE.Equals(type))
                {
                    // collect actual used fields for non-removed instrument profiles
                    foreach (InstrumentProfileField ipf in fields)
                    {
                        if (ipf != InstrumentProfileField.TYPE && ipf.GetField(ip).Length > 0)
                        {
                            if (enumFormat.Add(ipf))
                            {
                                updated.Add(type);
                            }
                        }
                    }
                    if (ip.AddNonEmptyCustomFieldNames(customFormat))
                    {
                        updated.Add(type);
                    }
                }
            }
            foreach (string type in updated)
            {
                WriteFormat(type);
            }
        }