Problem regarding the absorption lines of the sun Some of the wavelengths of light that are emitted from the sun will be absorbed by atoms in the outer layer of the sun and also the atmosphere of the sun, and we see this as absorption lines in the spectrum. Now, this absorbed radiation will indeed be re-emitted again, so one might think that these emission lines should &quot;cancel out&quot; the absorption lines. The usual explanation for why this doesn't happen is that the re-emitted light is radiated in all directions, not just towards us, meaning that to us these wavelengths will be much fainter than the other wavelengths.
But the problem I have is that this happens all around the sun (since the atmosphere is completely surrounding it), and intuitively it seems then that all of this re-emitted light should combine such that far away it would appear that the sun is radiating these wavelengths just as it is radiating all the other wavelengths. And if that is true, then we shouldn't see absorption lines in the spectrum. So what is it that I am missing?
Possibly you are labouring under the misapprehension that the number of photons is somehow a conserved quantity? That isn't true, there are more photons at any given wavelength when you are deeper into the star, because there is a temperature gradient. Cooler material further out is less emissive because fewer atoms are in excited states.
The temperature gradient is responsible for the formation of absorption lines. If the photosphere of the Sun were at a single temperature then we would see a perfect blackbody spectrum, for the reasons you outline.
The filling in of absorption by scattering would only take place if the radiation field that the atoms were in were isotropic. But it isn't isotropic because of the temperature gradient.
A much better way to think about the spectrum of a star is to imagine that you can see to a wavelength-dependent depth into the star. Where there is a strong atomic absorption feature, you cannot see very far into the star at that wavelength.
Since the star gets hotter the deeper you go into it, and the emissivity scales as $T^4$, then the deeper we can see into the star, the brighter it will appear at that wavelength (and vice-versa).
EDIT:
More formally. The radiative transfer equation, if you want to consider the absorption and remission as some sort of scattering process, would be
$$\frac{dI_{\nu}}{ds} = -\sigma_\nu I_{\nu} + \sigma_\nu J_\nu\ ,$$
where $I$ is the specific intensity in the solar photosphere (in this case, directed towards the Earth), $J$ is the mean specific intensity at a point in the solar photosphere averaged over all directions (i.e. $J = \int I d\Omega/4\pi$, where $\Omega$ is solid angle), $\sigma$ is the scattering coefficient (assumed to be isotropic) and $ds$ is a piece of pathlength towards the observer. The $\nu$ subscript just indicates everything is wavelength/frequency dependent.
To avoid creating an absorption or emission line then $dI_\nu/ds$ must equal zero (i.e. nothing is added or subtracted from the beam of light).
This will only happen if $I_\nu = J_\nu$, which would require that the  specific intensity averaged over all directions is equal to the specific intensity emerging from the Sun and heading towards the observer. This will only be true if the radiation field is isotropic and equal to $I_\nu$ in all directions.
Whilst this would be true for a blackbody radiation field at a set temperature,
it isn't true in the solar photosphere. The specific intensity heading towards us (generally outwards) is always larger than the specific intensity heading away (generally inwards and true regardless of which portion of the visible solar disc is considered) because of the temperature gradient in the photosphere, which means it is hotter further into the interior. That means that $I_\nu$ is always greater than $J_\nu$ and hence $dI_\nu/ds &lt; 0$ and we have net absorption.