Corrected delimiter state, added end of file check