If you read a line with the normal invocation of fgets, it terminates on a newline. It will terminate earlier if you give it a maximum length that is shorter than the line. If you copy non-comment lines to a temporary file, and don't copy comment lines, you have discarded them, right?
You are admittedly not a C expert. That doesn't matter at this point. You go sit behind the barn and watch the cotton grow while thinking about your problem, in logical terms. Once you understand what you have to do, in logical terms, given your data, then you translate those operations into the language of your choice. One of the reasons we are here is to help you do that last part correctly. We also help you with the first part, if you need it. It's called 'design.'