Read the API for the readLine method - given you don't post the code fully I can only guess what raf is (RandomAccessFile?), but typically this method returns null when the end of file is reached. So...