Yes, I see that the problem was that the $txt_url, $html_url, and $pdf_url variables were never reset to null when the new input did not have a txt, html, or pdf reference. Thus, those variables were re-inserted into the array every time a new line was read in. Your code solves the problem. I appreciate the help!