If you want to "clear old text then add new text to text file" then isn't that the same as overwriting the file with the new text? If so why need to clear old text?
Your FileWriter should probably be writing to the file denoted by 'filename' and not by 'name' and as K. Tsang has said there is no need to clear old text, just remove the 'true' parameter from the FileWriter constructor to overwrite the file with the new data.