diff --git a/src/spec2nexus/data/usaxs-bluesky-specwritercallback.dat b/src/spec2nexus/data/usaxs-bluesky-specwritercallback.dat
index 2d2b962..06198b2 100644
--- a/src/spec2nexus/data/usaxs-bluesky-specwritercallback.dat
+++ b/src/spec2nexus/data/usaxs-bluesky-specwritercallback.dat
@@ -21,7 +21,7 @@
 #MD tune_md = {'width': -0.004, 'initial_position': 8.824885, 'time_iso8601': '2019-04-19 10:04:44.402643'}
 #MD tune_parameters = {'num': 31, 'width': -0.004, 'initial_position': 8.824885, 'peak_choice': 'com', 'x_axis': 'm_stage_r', 'y_axis': 'I0_USAXS'}
 #MD badly-formed MD control line
-#N 31
+#N 14
 #L Epoch_float  Epoch  seconds  I0_USAXS  I00_USAXS  PD_USAXS  TR diode  I000  scaler0_time  scaler0_display_rate  m_stage_r  m_stage_r_user_setpoint  m_stage_r_soft_limit_lo  m_stage_r_soft_limit_hi
 2.424184560775757 2 1000000.0 166.0 3110.0 1315.0 1.0 226.0 0.1 5.0 8.826885 8.826885 -7.856115 37.143885
 2.8740737438201904 3 1000000.0 173.0 3111.0 1363.0 1.0 226.0 0.1 5.0 8.826751 8.826751666666667 -7.856115 37.143885
@@ -76,7 +76,7 @@
 #MD purpose = tuner
 #MD tune_md = {'width': -8, 'initial_position': 18.852700000000002, 'time_iso8601': '2019-04-19 10:05:02.907725'}
 #MD tune_parameters = {'num': 21, 'width': -8, 'initial_position': 18.852700000000002, 'peak_choice': 'com', 'x_axis': 'm_stage_r2p', 'y_axis': 'I0_USAXS'}
-#N 21
+#N 14
 #L Epoch_float  Epoch  seconds  I0_USAXS  I00_USAXS  PD_USAXS  TR diode  I000  scaler0_time  scaler0_display_rate  m_stage_r2p  m_stage_r2p_user_setpoint  m_stage_r2p_soft_limit_lo  m_stage_r2p_soft_limit_hi
 1.3263635635375977 1 1000000.0 8203.0 3098.0 99999.0 1.0 224.0 0.1 5.0 22.852700000000002 22.852700000000002 -20.0 90.0
 1.66495680809021 2 1000000.0 10621.0 3097.0 99999.0 1.0 225.0 0.1 5.0 22.4527 22.452700000000004 -20.0 90.0
@@ -121,7 +121,7 @@
 #MD purpose = tuner
 #MD tune_md = {'width': -0.004, 'initial_position': 8.883730900000002, 'time_iso8601': '2019-04-19 10:05:12.599316'}
 #MD tune_parameters = {'num': 35, 'width': -0.004, 'initial_position': 8.883730900000002, 'peak_choice': 'com', 'x_axis': 'a_stage_r', 'y_axis': 'PD_USAXS'}
-#N 35
+#N 14
 #L Epoch_float  Epoch  seconds  I0_USAXS  I00_USAXS  PD_USAXS  TR diode  I000  scaler0_time  scaler0_display_rate  a_stage_r  a_stage_r_user_setpoint  a_stage_r_soft_limit_lo  a_stage_r_soft_limit_hi
 1.7970309257507324 2 1000000.0 55898.0 3103.0 1.0 1.0 226.0 0.1 5.0 8.8857309 8.885730900000002 -5.0 30.0
 2.3183534145355225 2 1000000.0 55818.0 3103.0 1.0 1.0 226.0 0.1 5.0 8.885613200000002 8.885613252941178 -5.0 30.0
@@ -180,7 +180,7 @@
 #MD purpose = tuner
 #MD tune_md = {'width': -8, 'initial_position': 38.4243, 'time_iso8601': '2019-04-19 10:05:32.295550'}
 #MD tune_parameters = {'num': 31, 'width': -8, 'initial_position': 38.4243, 'peak_choice': 'com', 'x_axis': 'a_stage_r2p', 'y_axis': 'PD_USAXS'}
-#N 31
+#N 14
 #L Epoch_float  Epoch  seconds  I0_USAXS  I00_USAXS  PD_USAXS  TR diode  I000  scaler0_time  scaler0_display_rate  a_stage_r2p  a_stage_r2p_user_setpoint  a_stage_r2p_soft_limit_lo  a_stage_r2p_soft_limit_hi
 1.2613587379455566 1 1000000.0 57117.0 3102.0 399.0 1.0 226.0 0.1 5.0 42.4243 42.4243 -20.0 90.0
 1.5930070877075195 2 1000000.0 57188.0 3103.0 69.0 1.0 227.0 0.1 5.0 42.1576 42.15763333333334 -20.0 90.0
@@ -235,7 +235,7 @@
 #MD purpose = tuner
 #MD tune_md = {'width': -0.004, 'initial_position': 8.824867, 'time_iso8601': '2019-04-19 10:08:55.508993'}
 #MD tune_parameters = {'num': 31, 'width': -0.004, 'initial_position': 8.824867, 'peak_choice': 'com', 'x_axis': 'm_stage_r', 'y_axis': 'I0_USAXS'}
-#N 31
+#N 14
 #L Epoch_float  Epoch  seconds  I0_USAXS  I00_USAXS  PD_USAXS  TR diode  I000  scaler0_time  scaler0_display_rate  m_stage_r  m_stage_r_user_setpoint  m_stage_r_soft_limit_lo  m_stage_r_soft_limit_hi
 1.3442771434783936 1 1000000.0 191.0 3111.0 44.0 1.0 226.0 0.1 5.0 8.826867 8.826867 -7.856115 37.143885
 1.7606616020202637 2 1000000.0 214.0 3109.0 20504.0 1.0 226.0 0.1 5.0 8.826733 8.826733666666666 -7.856115 37.143885
@@ -290,7 +290,7 @@
 #MD purpose = tuner
 #MD tune_md = {'width': -8, 'initial_position': 19.1722, 'time_iso8601': '2019-04-19 10:09:12.175169'}
 #MD tune_parameters = {'num': 21, 'width': -8, 'initial_position': 19.1722, 'peak_choice': 'com', 'x_axis': 'm_stage_r2p', 'y_axis': 'I0_USAXS'}
-#N 21
+#N 14
 #L Epoch_float  Epoch  seconds  I0_USAXS  I00_USAXS  PD_USAXS  TR diode  I000  scaler0_time  scaler0_display_rate  m_stage_r2p  m_stage_r2p_user_setpoint  m_stage_r2p_soft_limit_lo  m_stage_r2p_soft_limit_hi
 1.1383028030395508 1 1000000.0 4299.0 3111.0 56.0 1.0 226.0 0.1 5.0 23.1722 23.1722 -20.0 90.0
 1.3771731853485107 1 1000000.0 5412.0 3098.0 99999.0 1.0 226.0 0.1 5.0 22.7722 22.7722 -20.0 90.0
@@ -335,7 +335,7 @@
 #MD purpose = tuner
 #MD tune_md = {'width': -0.004, 'initial_position': 8.8839199, 'time_iso8601': '2019-04-19 10:09:20.509031'}
 #MD tune_parameters = {'num': 35, 'width': -0.004, 'initial_position': 8.8839199, 'peak_choice': 'com', 'x_axis': 'a_stage_r', 'y_axis': 'PD_USAXS'}
-#N 35
+#N 14
 #L Epoch_float  Epoch  seconds  I0_USAXS  I00_USAXS  PD_USAXS  TR diode  I000  scaler0_time  scaler0_display_rate  a_stage_r  a_stage_r_user_setpoint  a_stage_r_soft_limit_lo  a_stage_r_soft_limit_hi
 1.3226919174194336 1 1000000.0 56605.0 3103.0 2.0 1.0 226.0 0.1 5.0 8.885919900000001 8.885919900000001 -5.0 30.0
 1.745370864868164 2 1000000.0 56503.0 3103.0 1.0 1.0 226.0 0.1 5.0 8.8858023 8.885802252941177 -5.0 30.0
diff --git a/src/spec2nexus/plugins/spec_common.py b/src/spec2nexus/plugins/spec_common.py
index c5c10f4..13f67ac 100644
--- a/src/spec2nexus/plugins/spec_common.py
+++ b/src/spec2nexus/plugins/spec_common.py
@@ -1404,6 +1404,14 @@ def data_lines_postprocessing(scan):
     
     :param SpecDataFileScan scan: data from a single SPEC scan
     """
+    if len(scan.L) != scan.N[0]:
+        raise ValueError(
+            "# of given column labels in #L ({}) "
+            "does not match # specified in #N ({})".format(
+                len(scan.L), scan.N[0]
+                )
+            )
+
     # first, get the column labels, rename redundant labels to be unique
     # the unique labels will be the scan.data dictionary keys
     scan.data = {}

Index error reading a single scan SPEC file
I am trying to read a SPEC file generated by a SPEC macro at CHESS, which contains a single scan. I get the following traceback:
```
$ spec2nexus scan.spec 
reading SPEC data file: scan.spec
Traceback (most recent call last):
  File "/Users/rosborn/miniconda3/envs/py38/bin/spec2nexus", line 8, in <module>
    sys.exit(main())
  File "/Users/rosborn/miniconda3/envs/py38/lib/python3.8/site-packages/spec2nexus/nexus.py", line 189, in main
    out.save(nexus_output_file_name, scan_list)
  File "/Users/rosborn/miniconda3/envs/py38/lib/python3.8/site-packages/spec2nexus/writer.py", line 89, in save
    self.save_scan(nxentry, self.spec.getScan(key))
  File "/Users/rosborn/miniconda3/envs/py38/lib/python3.8/site-packages/spec2nexus/writer.py", line 143, in save_scan
    scan.interpret()        # ensure interpretation is complete
  File "/Users/rosborn/miniconda3/envs/py38/lib/python3.8/site-packages/spec2nexus/spec.py", line 637, in interpret
    func(self)
  File "/Users/rosborn/miniconda3/envs/py38/lib/python3.8/site-packages/spec2nexus/plugins/spec_common.py", line 1049, in postprocess
    data_lines_postprocessing(scan)
  File "/Users/rosborn/miniconda3/envs/py38/lib/python3.8/site-packages/spec2nexus/plugins/spec_common.py", line 1443, in data_lines_postprocessing
    buf = scan._interpret_data_row(values)
  File "/Users/rosborn/miniconda3/envs/py38/lib/python3.8/site-packages/spec2nexus/spec.py", line 684, in _interpret_data_row
    buf[self.L[col]] = float(val)
IndexError: list index out of range
```
The output file gets created but only contains `/S1/definition`. I am running spec2nexus-2021.1.7 with Python 3.8 on Mac OS X v10.14.6. I am attaching the SPEC file (with `.txt` added to the extension so that Github accepted it).

[scan.spec.txt](https://github.com/prjemian/spec2nexus/files/3985926/scan.spec.txt)


diff --git a/tests/__init__.py b/tests/__init__.py
index 33fa94b..7ebc24e 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -49,6 +49,7 @@ def suite(*args, **kw):
     from tests import issue161
     from tests import issue188
     from tests import issue191
+    from tests import issue216
 
     test_list = [
         data_03_06_JanTest,
@@ -76,6 +77,7 @@ def suite(*args, **kw):
         issue161,
         issue188,
         issue191,
+        issue216,
         ]
 
     test_suite = unittest.TestSuite()
diff --git a/tests/issue216.py b/tests/issue216.py
index 9f8d963..01a04ff 100644
--- a/tests/issue216.py
+++ b/tests/issue216.py
@@ -4,6 +4,18 @@ spec2nexus issue #216: Index error reading a single scan SPEC file
 
 The output file gets created but only contains /S1/definition, 
 running spec2nexus-2021.1.7.
+
+This data file has problems which were not identified clearly
+until this issue.  All problems are related to incorrect formatting  
+of the `#L` line.  The number of columns specified in #N matches 
+the number of values on each data line (7).
+
+1. The number of columns specified in #N does not match the number
+   of columns described in #L
+2. The labels given on #L are only delimited by single spaces.
+   This results in only one label defined.
+3. The number of separate labels given in #L (6) does not equal the
+   number of data columns.
 '''
 
 #-----------------------------------------------------------------------------
@@ -63,26 +75,8 @@ class Issue216(unittest.TestCase):
         self.assertTrue(isinstance(scan, spec2nexus.spec.SpecDataFileScan))
 
         # force plugins to process
-        scan.interpret()
-
-        self.assertTrue(os.path.exists(self.tempdir))
-        nexus_output_file_name = os.path.join(
-            self.tempdir, 
-            os.path.basename(os.path.splitext(self.testfile)[0])
-            ) + ".h5"
-        self.assertFalse(os.path.exists(nexus_output_file_name))
-
-        out = spec2nexus.writer.Writer(sdf)
-        out.save(nexus_output_file_name, [scanNum,])
-
-        self.assertTrue(os.path.exists(nexus_output_file_name))
-        with h5py.File(nexus_output_file_name) as h5:
-            # check the NXentry/positioners:NXnote group
-            self.assertIn("/S1/definition", h5)
-            # TODO: test for other content
-            # 7 data columns (#N 7) but (#L EPOCH Phi CESR IC1 IC2 DIODE)
-            # 9 data points
-            # TODO: should supply default labels when len(#L) < int(#N[0])
+        with self.assertRaises(ValueError):
+            scan.interpret()
 
 
 def suite(*args, **kw):

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
coverage==7.2.7
cycler==0.11.0
docopt==0.6.2
exceptiongroup==1.2.2
execnet==2.0.2
fonttools==4.38.0
h5py==3.8.0
importlib-metadata==6.7.0
iniconfig==2.0.0
kiwisolver==1.4.5
lxml==5.3.1
matplotlib==3.5.3
numpy==1.21.6
packaging==24.0
Pillow==9.5.0
pluggy==1.2.0
pyparsing==3.1.4
pyRestTable==2020.0.8
pytest==7.4.4
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
six==1.17.0
-e git+https://github.com/prjemian/spec2nexus.git@62248b30843702ee19c72b2ee9c2204dd27e0c11#egg=spec2nexus
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0

name: spec2nexus
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.2.7
      - cycler==0.11.0
      - docopt==0.6.2
      - exceptiongroup==1.2.2
      - execnet==2.0.2
      - fonttools==4.38.0
      - h5py==3.8.0
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - kiwisolver==1.4.5
      - lxml==5.3.1
      - matplotlib==3.5.3
      - numpy==1.21.6
      - packaging==24.0
      - pillow==9.5.0
      - pluggy==1.2.0
      - pyparsing==3.1.4
      - pyresttable==2020.0.8
      - pytest==7.4.4
      - pytest-asyncio==0.21.2
      - pytest-cov==4.1.0
      - pytest-mock==3.11.1
      - pytest-xdist==3.5.0
      - python-dateutil==2.9.0.post0
      - six==1.17.0
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/spec2nexus

tests/issue216.py::Issue216::test_nexus_file
src/spec2nexus/data/usaxs-bluesky-specwritercallback.dat src/spec2nexus/plugins/spec_common.py
src/spec2nexus/data/usaxs-bluesky-specwritercallback.dat src/spec2nexus/plugins/spec_common.py