Debugged script, still getting a couple of errors

- added in test for header line
- need to address issue with uninitialized values error