# File-In node oddities

**URL:** <https://discourse.nodered.org/t/file-in-node-oddities/17121>\
**Category:** General\
**Created:** [25 October 2019 08:13 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121 "2019-10-25T08:13:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [25 October 2019 08:13 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/1 "2019-10-25T08:13:15Z")

</div>

I may be the odd one here but wanted to check if this behaviour is normal, or if it's just me 🙂

I have a File-In node set to output "a msg per line". All works as expected except for the **last line** , which either:  
a) will not output the full msg (the Topic is missing) if there is no LF; or  
b) will output the next blank line as a msg if there is a LF.

The outcome I would like is a) but obviously with the complete msg.

There are obviously easy workarounds for this, but I am just curious if anyone else gets the same outcome.

Thanks

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [25 October 2019 08:56 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/2 "2019-10-25T08:56:50Z")

</div>

I see the same thing. The msg.topic is sent thru on every line but the last line of the file.  
 ![50%20AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fbc24e057c1701a8f86304a3041eda0f213346be.png)

```auto
10/25/2019, 4:50:12 AMnode: cf302004.413cd8
test out : msg : Object
{ payload: "line 1", topic: "test out", filename: "/Users/Paul/test.txt", parts: object, _msgid: "5fdf0b45.3adad4" }

10/25/2019, 4:50:12 AMnode: cf302004.413cd8
test out : msg : Object
object
  payload: "line 2"
  topic: "test out"
  filename: "/Users/Paul/test.txt"
  parts: object
    index: 1
    ch: "↵"
    type: "string"
    id: "27cda854.0a2fc8"
  _msgid: "c3a748f6.3b23b8"

10/25/2019, 4:50:12 AMnode: cf302004.413cd8
msg : Object
object
  payload: "line 3"
  parts: object
    index: 2
    count: 3
  ch: "↵"
    type: "string"
    id: "27cda854.0a2fc8"
 _msgid: "37349951.ffffa6"

```

 ![10%20AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b1687068788be057a31eef0ffd7345e575c49217.png)

```auto
[{"id":"a8c74407.ec8b58","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"d5fe1576.59f688","type":"file in","z":"a8c74407.ec8b58","name":"","filename":"/Users/Paul/test.txt","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":390,"y":860,"wires":[["cf302004.413cd8"]]},{"id":"aaf27b4b.03a708","type":"inject","z":"a8c74407.ec8b58","name":"","topic":"test out","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":860,"wires":[["d5fe1576.59f688"]]},{"id":"cf302004.413cd8","type":"debug","z":"a8c74407.ec8b58","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":860,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [25 October 2019 09:00 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/3 "2019-10-25T09:00:25Z")

</div>

Thanks Paul, glad it's not just me 😅

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [25 October 2019 10:16 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/4 "2019-10-25T10:16:51Z")

</div>

FYI, I just submitted a PR to fix this. It was a one line addition to the code.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [25 October 2019 10:32 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/5 "2019-10-25T10:32:18Z")

</div>

Just looked at PR - maybe add a link to this thread for info?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [25 October 2019 10:35 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/6 "2019-10-25T10:35:49Z")

</div>

Good idea - done!

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [7 December 2019 07:00 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/7 "2019-12-07T07:00:57Z")

</div>

Anyone know if this was fixed? I couldn't find Paul's PR for it.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 December 2019 10:11 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/8 "2019-12-07T10:11:12Z")

</div>

I don't thnk it made it into 1.0.3 so it should beinthe next release

> <https://github.com/node-red/node-red/pull/2352>

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [7 December 2019 10:19 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/9 "2019-12-07T10:19:18Z")

</div>

Thanks Paul.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [7 December 2019 10:20 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/10 "2019-12-07T10:20:59Z")

</div>

em - AFAICT the changed code IS in 1.0.3

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1e24a0996141d7261147a3463a041247646227f4.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 December 2019 10:30 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/11 "2019-12-07T10:30:05Z")

</div>

Duhh, I went and tested it and it didn't work but @cymplecy made me think so I went and looked and (head slap) The place I just tested it is on 1.0.2 (double head slap)

yup it is in 1.0.3 (Thanks Simon!)

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [14 December 2019 03:57 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/12 "2019-12-14T03:57:32Z")

</div>

Ok, well this appears to be some sort of Friday 13th joke but...

the issue of sending an extra msg at the end of the file still appears to exist, when the File In node is set to "a msg per line". I notice that the filename property is missing from the last msg.

Can someone else confirm?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 December 2019 10:44 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/13 "2019-12-14T10:44:08Z")

</div>

You are correct that filename is missing  
 ![Screen Shot 2019-12-14 at 5.25.58 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3155285f269a0511130a8f8e3e02093a0f36eab2.png)

If you go read the [Pull Request](https://github.com/node-red/node-red/pull/2352) you will see that @dceejay was concerned that th message needed to be cloned and worried about the hit to performance and that would take some thinking after they got out v1.0.3. So the pr to fix getting the last message was accepted but there are still issues with everything that comes out with the last message.

For example, if you put a change node before the `file-in` node and set 'msg.mytest' to 'cheers!', it does not come out as part of the msg that exits the `file-in` node.

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [14 December 2019 13:36 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/14 "2019-12-14T13:36:39Z")

</div>

Sorry, not following. How does that affect the fact that an extra msg is being sent **with an empty payload** when it shouldn't? Or is it just me seeing this?

> [@zenofmud](#):
>
> it does not come out as part of the msg that exits the `file-in` node.

I thought this behaviour was as expected, in that only msg.payload or msg.topic would be passed on?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 December 2019 13:57 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/15 "2019-12-14T13:57:28Z")

</div>

My input file has three line. All three lines are showing in the debug and nothing else.

Have you updated node-red to 1.0.3?

Is it possible you have a blank line at the end of the file?

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [14 December 2019 14:32 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/16 "2019-12-14T14:32:31Z")

</div>

> [@zenofmud](#):
>
> My input file has three line. All three lines are showing in the debug and nothing else.

I was afraid you would say that.

> [@zenofmud](#):
>
> Have you updated node-red to 1.0.3?

Yes.

> [@zenofmud](#):
>
> Is it possible you have a blank line at the end of the file?

I have created a number of test files with and without linefeeds at the end just to see the results. All the same, with one extra msg tacked on the end. As previously mentioned, the last msg has no filename property, and also no payload.

Grrr, hate mysteries.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [14 December 2019 14:34 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/17 "2019-12-14T14:34:39Z")

</div>

How about you two exchanging files to test out?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 December 2019 15:01 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/18 "2019-12-14T15:01:20Z")

</div>

Here is my test file - three lines with  
line 1  
line 2  
line 3  
[test.txt](https://discourse.nodered.org/uploads/short-url/5KirKE0g8MmQ7MGiC4EGgLn47vv.txt) (20 Bytes) [test.txt](https://discourse.nodered.org/uploads/short-url/aSvINORaQi2m5UYutjIHWg9QnWS.txt) (21 Bytes)  
and here are my settings:  
 ![Screen Shot 2019-12-14 at 10.00.45 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e47f7bad72c6aa4824faa00424d7ad95edd37ffa.png)  
and here is the debug:

```auto
12/14/2019, 10:02:37 AMnode: efa512e0.b2a2e
test out : msg : Object
{ payload: "line 1", topic: "test out", filename: "/Users/Paul/test.txt", parts: object, _msgid: "9012d0a8.67584" }
12/14/2019, 10:02:37 AMnode: efa512e0.b2a2e
test out : msg : Object
{ payload: "line 2", topic: "test out", filename: "/Users/Paul/test.txt", parts: object, _msgid: "7dc19a9.d5c7664" }
12/14/2019, 10:02:37 AMnode: efa512e0.b2a2e
test out : msg : Object
{ payload: "line 3", topic: "test out", parts: object, _msgid: "6d08dff6.1fb15" }

```

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [14 December 2019 15:06 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/19 "2019-12-14T15:06:20Z")

</div>

Apologies for wasting everyone's time on this. 😒

Apparently the editor Nano must be used with the -L switch to suppress eof linefeed. Even though without -L the editor doesn't count the extra line. Think it's time to find a better editor.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [14 December 2019 15:26 UTC](https://discourse.nodered.org/t/file-in-node-oddities/17121/20 "2019-12-14T15:26:55Z")

</div>

> [@Bobo](#):
>
> Apparently the editor Nano must be used with the -L switch to suppress eof linefeed

I never knew that!

But I think nano was designed to be the muggle editor for Linux so given that, adding the extra LF would be considered a good feature for people using it to edit config files

Now I know about it, I can save that one extra keypress 🙂

[Next page](https://discourse.nodered.org/t/file-in-node-oddities/17121.md?page=2)
