# Don't understand the expected solution on stage #ER2

**URL:** <https://forum.codecrafters.io/t/dont-understand-the-expected-solution-on-stage-er2/1074>\
**Category:** Challenges\
**Tags:** challenge:interpreter\
**Created:** [July 16, 2024, 4:50pm UTC](https://forum.codecrafters.io/t/dont-understand-the-expected-solution-on-stage-er2/1074 "2024-07-16T16:50:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shizey](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shizey/32/990_2.png) [@Shizey](https://forum.codecrafters.io/u/Shizey)\
**Post date:** [July 16, 2024, 4:50pm UTC](https://forum.codecrafters.io/t/dont-understand-the-expected-solution-on-stage-er2/1074/1 "2024-07-16T16:50:34Z")

</div>

I’m stuck on Stage #ER2.

I don’t understand why the expected solution for the test-2 in #ER2 have a single EOF while we have two lines :

```auto
[tester::#ER2] [test-2] Running test case: 2
[tester::#ER2] [test-2] Writing contents to ./test.lox:
[tester::#ER2] [test-2] [test.lox] <|TAB|>
[tester::#ER2] [test-2] [test.lox] <|SPACE|>
[tester::#ER2] [test-2] $ ./your_program.sh tokenize test.lox
[your_program] Logs from your program will appear here!
[your_program] EOF null
[your_program] EOF null
[tester::#ER2] [test-2] ✓ EOF null
[tester::#ER2] [test-2] ! EOF null
[tester::#ER2] [test-2] Expected last stdout line to be "EOF null", but found extra line: "EOF null"
[tester::#ER2] [test-2] Test failed

```

---

<div class="post-metadata">

**Author:** ![rohitpaulk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rohitpaulk/32/6_2.png) [@rohitpaulk](https://forum.codecrafters.io/u/rohitpaulk)\
**Post date:** [July 16, 2024, 4:52pm UTC](https://forum.codecrafters.io/t/dont-understand-the-expected-solution-on-stage-er2/1074/2 "2024-07-16T16:52:03Z")

</div>

EOF stands for “end of file” - it’s only expected that one EOF token is emitted for every file parsed.

---

<div class="post-metadata">

**Author:** ![pri-shav](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/pri-shav/32/1057_2.png) [@pri-shav](https://forum.codecrafters.io/u/pri-shav)\
**Post date:** [July 23, 2024, 12:38pm UTC](https://forum.codecrafters.io/t/dont-understand-the-expected-solution-on-stage-er2/1074/3 "2024-07-23T12:38:34Z")

</div>

Hello 😇

As per my knowledge, This could be due to an extra newline or an additional EOF being printed.

Make sure your program only outputs “EOF null” once. Check your code for any loops or conditions that might cause the EOF message to print multiple times. If you’re using a loop to read the file, ensure it terminates correctly after the first EOF.

I hope this will help you. 😍

Respected community member 🥰

---

<div class="post-metadata">

**Author:** ![Shizey](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shizey/32/990_2.png) [@Shizey](https://forum.codecrafters.io/u/Shizey)\
**Post date:** [July 24, 2024, 7:07pm UTC](https://forum.codecrafters.io/t/dont-understand-the-expected-solution-on-stage-er2/1074/4 "2024-07-24T19:07:01Z")

</div>

Thank you, I don’t know why I thought that EOF was for end of line lol.

---

<div class="post-metadata">

**Author:** ![Shizey](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shizey/32/990_2.png) [@Shizey](https://forum.codecrafters.io/u/Shizey)\
**Post date:** [July 24, 2024, 7:07pm UTC](https://forum.codecrafters.io/t/dont-understand-the-expected-solution-on-stage-er2/1074/5 "2024-07-24T19:07:41Z")

</div>

Yes indeed, I print EOF at each end of line but it’s just end of line.

Thanks for your help =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [July 29, 2024, 7:08pm UTC](https://forum.codecrafters.io/t/dont-understand-the-expected-solution-on-stage-er2/1074/6 "2024-07-29T19:08:40Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
