You have the right idea in write_to_file()
, but print_file()
is awkward.
There is no need to work a character at a time in print_file()
. You can read a line at a time using fgets(buffer, sizeof(buffer), in_file)
.
Avoid flag variables. Here, you could use a for loop to track the line number instead.
char buffer[MAX_SIZE];
for (int i = 0; fgets(buffer, sizeof(buffer), in_file) != EOF; ++i) {
if (i != 1) puts(buffer);
}