Fixed error in file write statement