Agustina,
Looks like you're parsing GenBank records. Have you looked into
Bioperl? It has methods to read and parse files in GenBank format, and the feature data is accessible using the SeqFeature object. You may still need to do some trimming/cleanup here and there, but it might simplify your parsing.
-
robsv