in reply to File not opening, but no error report

if ($lines[$i] =~ /$regex[$i]/)

If $lines[0] doesn't match /file/ then you never will execute if body and never will increment $i, so you always would match $lines[0] against /file/.

Update: typo fixed