Using PrintWriter instead on BufferedOutputStream and the println method instead of write works very well but the autoflush option must be enabled while creating a PrintWriter Object.
Also using print (instead of println) dosen't work because println inserts a line separator
string ( "/n" : system dependant) at the end of user entered string which is required for autoflushing
