added EOF detection to tag parser