Hello, perlnobie, and welcome to the Monastery.
Please, use <code> </code> tags to make your code readable. Try telling us what the script is supposed to do. You seem to be troubled by the fact that it does not output any data. What data should it produce?
The code you posted starts by opening a file for input. What is this input? The code you posted manipulates the input data. If it is empty, or does not fit the expected patterns, then no wonder that the output file is empty.
Help us by providing some further information.