I don't understand the need for a line_number or the why we need to separate out the comments from entries.

Maybe I'm missing something.

I believe @entries could contain all lines
1) regular ones having a device - these are treated as they always have on read and write
2) ones with a comment
3) blank ones (ones without a device or comment)

We can then read them and store them in @entries and do the right thing with setting the entry attributes by only setting the relevant attributes, such as comments only having the comment attribute, device ones having the other attributes set, and blank lines having nothing set.

Then, when we want to write them, we just loop through @entries one line at a time, writing normal entries as we do now, writing entries with a comment as the comment, and ones without a command or a device as an empty line.

Thoughts?