We can only tell from the example data.
pelagic's regex is also unsafe. what if the line looks like
ATOM 3316 N TYR B 24 97.479 18.805 2.990 1.00 36.32
+ D N
Then the alone "D" at the end will be replaced by "X". Intended??
I would use the substr()-solution above. My regex was just meant as an optimization of
perlsen's one, which is unneccesary complicated.
Update: Striked the sillyness about the second "D".
/me writes "Must read the question properly" 200 times.