Writes the same string to a file and to the screen using a common method