#===============================================================================================
# read data from file  
# receives: name of the file
# returns:  file data as a single string
#===============================================================================================
def read(infile):
 
    try:
        input = open(infile,'r')                    #Open file for reading - default 'r'    
        string = input.read()                       #read entire file into a string                
        input.close()                               #close the file
    except:
        print('Error - Cannot read file: ' + infile)
        exit()
    
    return(string)                              #return entire file as a string

#===============================================================================================
# write data to file  
# receives: string to write (multiple lines separated with \n )
# returns:  success True/False
#===============================================================================================
def write(outfile, string):

    try:
        output = open(outfile,'w')             #Open file for writing    
        output.write(string)                   #write all the records                
        output.close()                         #close the file        
        return(True)
    except:
        return(False)
    
#===============================================================================================