diff --git a/src/game_tab/right_panel/GameTabRightPanel.cpp b/src/game_tab/right_panel/GameTabRightPanel.cpp
index 3a46f59..dd0ebca 100644
--- a/src/game_tab/right_panel/GameTabRightPanel.cpp
+++ b/src/game_tab/right_panel/GameTabRightPanel.cpp
@@ -89,7 +89,12 @@ void GameTabRightPanel::OnCommentChange(wxCommandEvent &event) {
   wxLogDebug("GameTabRightPanel: comment input change");
   HalfMove *m = game->GetCurrentMove();
   if (m != nullptr) {
-    m->comment=event.GetString().ToStdString();
+    m->comment=event.GetString().Trim().ToStdString();
+    // Remove newlines:
+    for(char &c:m->comment){
+      if(c=='\n')
+        c=' ';
+    }
   }
   editor_canvas->Refresh();
 }
diff --git a/src/game_tab/right_panel/GameTabRightPanel.hpp b/src/game_tab/right_panel/GameTabRightPanel.hpp
index aa28f17..6f3aaaa 100644
--- a/src/game_tab/right_panel/GameTabRightPanel.hpp
+++ b/src/game_tab/right_panel/GameTabRightPanel.hpp
@@ -1,3 +1,5 @@
+#include <algorithm>
+
 #include "../Game.hpp"
 #include "LiveEngineDialog.hpp"
 #include "editor/EditorCanvas.hpp"