Makes less error prone to find file type. Updates #1197 PiperOrigin-RevId: 302974244
PiperOrigin-RevId: 291471892