Thanks for spending time to write the code, helped a lot. But is there a way for me to apply this to a big chunk of data ? I mean, the aminoacid groups go as long as 1,2,...............264 and there can be 2600something ATOM lines depending on the PDB file.