refactoring: Putting repeating code to funcitons

* Added openFileInEditor function.