I don't see where you are closing file_name1 before trying to open it again in read mode.