Moved fgets infront of if statement in order to prevent double posting of final line.