Improved patch for #1922 to support the Write() API for multiple records.
My first patch set Index=1 in WriteFile() and WriteString() so that
the output format plugin could perform any initialization. This worked,
but there was still a problem with some formats when saving multiple
records, including the CML format.
The CML format uses <molecule> as the top-level element when there is
only one input molecule, and <cml> as the top-level element when there
are two or more molecules. The <cml> element contains a sequence of
<molecule> elements.
If Index==1 and IsLast()==true then it's a single-molecule file.
If Index==1 and IsLast()==false then it's a multi-molecule file.
However, OBConversion::Write() always called SetOneObjectOnly(),
which set Last=true, so the CML format always thought it was writing
a single-record output file.
The fix was to remove SetOneObjectOnly() from the Write() and
do more intialization in WriteFile() and WriteString(). Previously
Write() did Index++ *after* calling the format's WriteMolecule().
This was incorrect. It needs to be done *before*, so the value
of GetOutputIndex() matches the number of molecules which were
sent as output. (This is a better emulation of how Convert() works.)
This in turn means WriteFile() and WriteString() need to reset
Index to 0. They then call Write(), which increments Index, so
WriteMolecule() always sees Index=1 for the first molecule.