in reply to file header change
This might not be the most efficient way but it is easy to understand :
I am assuming you are working with several pep files, so you read the input into an array.
You can split this array at the '>' with the split function, this way each of the proteins gets their own element.
To manipulate this further you can split each element into multiple lines by splitting at the \n. Now, your protein info will be in the th element of the array, and you can manipulate it however you want. The 1, 2, 3 will be an incrementing counter.
Like I said, not the most elegant, but it's a simple enough method that I've used. Glad if it helps. :)