def normalizeCode(codestring):
    """
    Function to normalize the given code.
    
    @param codestring code to be normalized
    @type str
    @return normalized code
    @rtype str
    """
    codestring = codestring.replace('\r\n', '\n').replace('\r', '\n')
    if codestring and codestring[-1] != '\n':
        codestring = codestring + '\n'
    return codestring
