Fix bug for writing smiles with flags