Fix bug when writing records. First record was omitted while writing field names.