You should figure out some naming scheme for the files you save. One method that has worked well in the past is to give each file a name indicating which homework assignment the file is for, as well as whether the file contains output or programming statements.
For example, for your first homework assignment, you would save your program as hw1.pgm, and your output file as hw1.out. For the second assignment, hw2.pgm and hw2.out. Using this system, you will always know what is in a file just by looking at its name.