def write_output_files(self,traj):
        """
        The total hydrogen bond count per frame is provided as CSV output file.
        Each trajectory has a separate file.
        """
        try:
            os.chdir("analysis")
        except Exception as e:
            os.mkdir("analysis")
            os.chdir("analysis")
        os.mkdir("pistacking")
        os.chdir("pistacking")
        with open('pistacking_data_total_'+str(traj)+'.csv', 'wb') as outfile:
            hwriter = csv.writer(outfile, delimiter=' ')
            for time in self.pistacking_by_time[traj]:
                hwriter.writerow([time[0],time[1]])
        for bond in self.pistacking_by_type[traj]:
            if bond in self.pi_contacts_for_drawing.keys():
                with open("pi_contact_"+str(traj)+".csv","wb") as outfile:
                    hwriter = csv.writer(outfile, delimiter=' ')
                    for time in self.timesteps:
                        result = [1 if x[0]==time and x["acceptor_idx"]==bond["acceptor_idx"] else 0 for x in self.timeseries][0]
                        hwriter.writerow([time,result])
        os.chdir("../../")