writer.write(wholeNote);
writer.flush();
writer.close();
//Update database to add a new note
Notes theNote = new Notes(noteName);
if (notesService.findOne(theNote.getFileName()) == null) {
Set<Users> noteUsers = new HashSet<Users>();
noteUsers.add(u);
theNote.setUsers(noteUsers);
notesService.save(theNote);
userFromDB.addNote(theNote);
Users savedUser = usersService.save(userFromDB.getId(), userFromDB);
session.setAttribute("userSession", savedUser);