My eyes! The goggles do nothing!
Aside from
- the lack of meaningful indentation because there's no <code> tags
- the lack of error checking on open calls
- the completely bizarre internesting of three different while loops
- the context free naming of variables
- the absence of correct variable declarations despite the presence of use strict (which just means this code could never have run to begin with)
- the probable misuse of != for ne (although that's just a guess; see next item)
- and the complete lack of sample data or expected results
What exactly's the problem?