Refactored the state machine code to have each state have its own function and fixed output to not get seg fault
Added newline counts and appropriate error handling with the newlines
Added comments into the shell script and the parser