Switch to sed rather than trying to use head. There may or may not be a second match, so need sed logic to understand whether it's a match or not to keep or throw out.