I am assuming it is this try catch try { using (StreamWriter w = File.AppendText(kspDir + 'isa_RAM_Mapper/isa_RAM_' + bodyName + '_Data.csv')) { while( isa_RAM_Buffer.Count > 0 ) { w.WriteLine(isa_RAM_Buffer.Dequeue ()); } w.Close (); isa_RAM_Pass_Count = 1; } } catch (IOException e) { Console.WriteLine('File Write Error. Pass #' + isa_RAM_Pass_Count + ' (' + e + \')\'); ++isa_RAM_Pass_Count; } if so, do this to check that it is actually an IOException by changing the IOException to Exception then using the ToString method to find out the actual cause of the exception. Note, do not leave it as exception, once you know what is can cause it, use the correct exception. try { using (StreamWriter w = File.AppendText(kspDir + 'isa_RAM_Mapper/isa_RAM_' + bodyName + '_Data.csv')) { while( isa_RAM_Buffer.Count > 0 ) { w.WriteLine(isa_RAM_Buffer.Dequeue ()); } w.Close (); isa_RAM_Pass_Count = 1; } } catch (Exception e) { Console.WriteLine(e.ToString()); //Console.WriteLine('File Write Error. Pass #' + isa_RAM_Pass_Count + ' (' + e + \')\'); //++isa_RAM_Pass_Count; }