با سلام و عرض خسته نباشید

من یک برنامه باید بنویسنم که در اون ما یک فایل متنی می سازیم و کاربر تا هر مقدار که خواست می تونه در این فایل متنی که ساخته شده بنویسه و به محض اینکه این کاربر یک رشته خالی رو ارسال کرد این برنامه خارج بشه و فایل ساخته شده تکمیل بشه.
برای ساخت این برنامه من از حلقه while استفاده کردم. و وقتی که کاربر متنی رو می نویسه و بعد که به خط جدید میره و کلید اینتر رو میزنه ولی برنامه از حلقه خارج نمیشه؟
مشکل کجا هست و شما چه پیشنهادی برای نوشتن این برنامه دارین؟
پیشاپیش تشکر از پاسخ گویی تون
کدی که نوشم:

import java.io.*;
import java.util.Scanner;
public class lesson {
public static void main (String[] args) throws IOException {
// we name our file,
File file = new File("filewecreate.txt");
Scanner input = new Scanner(System.in);
// we create a new file in project folder if the file with this name does not exist,
if (file.exists() == false) {
file.createNewFile();
}

// we make an instance of PrintWriter to write in our text file.
PrintWriter pw = new PrintWriter(file);

// the variable will save the input inside
String userInput;
System.out.println("Enter a text line here: ");

// the while loop will check the input each time user press enter or go to a new line and the if statement inside loop will break
// the loop if the input is null or ""
while (true) {
userInput = input.next();
pw.println(userInput);
if (userInput == "") {
break;
}
}

// we close the PW
pw.close();

// And at last we print out the Done message to show the user that program has been ran successfully
System.out.println("Done");
}

}