There are cases in uniprot where the AC ids occupies more than one line, for example, here. As the script is currently written, it overwrites the first line of AC and only writes out the 2nd line. The first occurrence of AC includes the primary accession. I've changed things so it checks that the accession is empty before overwriting it. If it isn't empty, appends instead. I believe this fixes the issue.
There are cases in uniprot where the AC ids occupies more than one line, for example, here. As the script is currently written, it overwrites the first line of AC and only writes out the 2nd line. The first occurrence of AC includes the primary accession. I've changed things so it checks that the accession is empty before overwriting it. If it isn't empty, appends instead. I believe this fixes the issue.