Youssef,
I cleaned up your code so you can see what is going on, my comments are in-line in the code:
Looking at your code, there are a lot of things done that just do not work in the real world--you have to know what is there before you can read it. In all of your reads, you don't know and that is very very bad. If you are going to use a Scanner object, along with another form of input, you still have to be sure both have data waiting and that the data is appropriate for what you want to read.
Put some println statements in your loop and throughout your code to see what is happening--and if execution is even reaching those points you think they are. From your previous comments of 1 line in the file, you are not even executing your while 1 time because you read that line long before you get to your loop. And in the case of you have more than 1 line in your file, then you actually hit your while loop and there is where I will assume that it hangs from all of the UNCHECKED reads you do.
If you need to read from the Scanner make a little
test program that reads from the Scanner object like you use in your program, and get it working. Know this: you have to check to see if you have the appropriate input BEFORE you read using the Scanner object. You can do a hasNextLine() and then read the individual data items from the line, which may leave that last return hanging in the file, or better IMO is to read the full line and parse it. But you have to check BEFORE you read.
Remember to keep your programs clean and formatted appropriately, it will make a world of difference. Stacking commands on a line does nothing for you in Java except make your program very difficult to read and follow. Java has a smart compiler, the JIT Compiler, and what ever you put on your page is modified by the JIT Compiler to be as optimal as it can make it, and good clean code is what makes the difference, not white space or the lack there of, to the JIT Compiler.
You have some major rewriting of this to do, to get rid of ALL of those uncheck reads: never be afraid to refactor your work, even to the point of do it all over--sometimes that is the best approach.
Any ways, have fun.
Les