I'm having this problem as well - I download a message using the same sort of script and gmail marks them as read; I log back into the gmail account, mark them as unread and the POP3 interface still refuses to find them.
POP3 may not take into account READ/UNREAD, but gmail does.