The mistake is that I am not flushing the data from the stream to the file everytime I decide to write a number. So every time the data is in the stream and not getting written to the file as a result the Buffered reader is reading null everytime. I have to just add:
if(!doesExist(mobileNo)){
writer.println(mobileNo);
writer.flush()
}