Problem solved: catch the correct opened file