Why does my python code write random symbols on the write() function PYTHON 2.7 : I have this python code:

    f = open("database.txt", "r+")
    
    f.write("Hello!")
    print f.read()
    f.close()

and when I run the code the idle shows me:  -t

But when I see the database.txt file this is whats inside:

Hello!t   stdouts   #007700t   stderrc         C   s   | |  _  d  |  _ d  S(   N(   R4   R*   t   owin(   R   R4   (    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyR   …   s    	c         C   s0   |  j  s |  j ƒ  n  |  j  j | | | ƒ d  S(   N(   RP   t   setupR   (   R   R   R   R   (    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyR   ‰   s    	
c         C   sx   t  |  j ƒ |  _ } | j } x6 |  j j ƒ  D]% \ } } | r/ | j | |  q/ q/ W| j d ƒ |  j j |  _ d  S(   Nt   sel(	   R   R4   RP   R   t   tagdefst   itemst
   tag_configuret	   tag_raiseR   (   R   RP   R   t   tagt   cnf(    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyRQ   Ž   s    	
(   RG   RH   RS   R   R   RQ   (    (    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyRK   }   s   		(    (	   t   Tkintert   idlelib.EditorWindowR   R-   R2   t   idlelibR   R   RK   (    (    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyt   <module>   s   
vWindow.pyt   short_title   s    c         C   s   |  j  ƒ  r d Sd Sd  S(   Nt   yest   no(   t	   get_saved(   R   (    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyt	   maybesave   s    t   insertc         C   ss   t  | t ƒ r< y t | t j ƒ } Wq< t k
 r8 q< Xn  |  j j | | | ƒ |  j j | ƒ |  j j	 ƒ  d  S(   N(
   t
   isinstancet   strt   unicodeR   t   encodingt   UnicodeErrorR   R   t   seet   update(   R   t   st   tagst   mark(    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyt   write%   s    
c         C   s"   x | D] } |  j  | ƒ q Wd  S(   N(   R   (   R   t   linest   line(    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyt
   writelines2   s    
c         C   s   d  S(   N(    (   R   (    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyt   flush6   s    t   Cuts   <<cut>>t   rmenu_check_cutt   Copys   <<copy>>t   rmenu_check_copyt   Pastes	   <<paste>>t   rmenu_check_pastes   Go to file/lines   <<goto-file-line>>s   file "([^"]*)", line (\d+)s   ([^\s]+)\((\d+)\)s   ^(\s*\S.*?):\s*(\d+):s   ([^\s]+):\s*(\d+):s   ^\s*(\S.*?):\s*(\d+):c   	      C   sô   |  j  d  k rQ g  } x- |  j D]" } | j t j | t j ƒ ƒ q W| |  _  n  |  j j d d ƒ } |  j	 | ƒ } | sÅ |  j j d d ƒ } |  j	 | ƒ } | sÅ t
 j d d d |  j ƒd  Sn  | \ } } |  j j
 | ƒ } | j | ƒ d  S(   Ns   insert linestarts   insert lineends   insert -1line linestarts   insert -1line lineends   No special linesT   The line you point at doesn't look like a valid file name followed by a line number.t   parent(   t   file_line_progst   Nonet   file_line_patst   appendt   ret   compilet
   IGNORECASER   t   gett   _file_line_helpert   tkMessageBoxt	   showerrort   flistt   opent   gotoline(	   R   t   eventt   lt   patR   t   resultR
   t   linenot   edit(    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyR   N   s(     	
c         C   sª   xz |  j  D]k } | j | ƒ } | r
 | j d d ƒ \ } } y t | d ƒ } | j ƒ  PWqu t k
 rq q
 qu Xq
 q
 Wd  Sy | t | ƒ f SWn t k
 r¥ d  SXd  S(   Ni   i   t   r(	   R)   t   searcht   groupR5   t   closet   IOErrorR*   t   intt	   TypeError(   R   R   t   progt   matchR
   R;   t   f(    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyR1   i   s    


(    (   R"   s   <<cut>>R#   (   R$   s   <<copy>>R%   (   R&   s	   <<paste>>R'   N(   NNN(   s   Go to file/lines   <<goto-file-line>>N(   t   __name__t
   __module__t   __doc__R   R   R
   R   R   R    R!   R*   t   rmenu_specsR+   R)   R   R1   (    (    (    s'   C:\Python27\lib\idlelib\OutputWindow.pyR      s*   					
				t   OnDemandOutputWindowc           B   sE   e  Z i i d  d 6d 6i d d 6d 6Z d „  Z d „  Z d „  Z RS(   t   bluet
   fore

