Ok I guess my hint wasn't good enough.
Output = new FileOutputStream("myfile.txt");
You have this inside the while loop. With each iteration of the loop you were creating a new instance of that file and essentially overwriting what was written to it the previous iteration. That is why your original code was only writing the last line to the text file.